Giter Club home page Giter Club logo

ahk2-bigint's Introduction

BigInt

Arbitrary precision integer library for AutoHotkey v2 (alpha)

Goals

  • Be easy to use, straightforward, consistent, accurate, and fast
  • Ensure accuracy and validity through unit tests
  • Any base as input and output (given char list of course)
  • Include as many functions as possible & reasonable for an integer lib
  • Pure AHK(2) solution. Not rely on third-party extensions, binaries, dll, or web requests to Wolfram|Alpha.

Change Requirements

These are the requirements for all changes.

  • A user function may NOT modify this or any args passed. Use obj.clone() or new BigInt(...) instead, and return a different BigInt object
  • Any additions or changes to the library must pass all current unit tests, include unit tests relevant to the change, AND prove that it does not modify the original objects. (see BigIntUnitTest.ahk2 for examples)
  • If possible, accept arguments that can be either BigInt instances OR normal ahk numbers.
  • User functions should have short names consisting only of lower-case characters, and be at least mildly self-descriptive. Internal functions, including functions that may modify this and other args, should be prefixed with one or more underscores.

ToDo

  • I'm considering changing it so all functions have a counterpart that does modify this. They would be prefixed with one underscore, and of course have a non-this-modifying version that acts exactly like the current functions.

Usage Examples

Regular Math:

x := new BigInt(55)

MsgBox % x.div(new BigInt(5)).__string()  ; integer division

MsgBox % x.mult(33).__string()  ; multiplication

y := new BigInt(0x800)

MsgBox % y.shl(400).__string()  ; left shift by 400 bits

MsgBox % y.shr().__string()  ; right shift (1 is default)

Take a really big number, and square it a bunch of times:

x := new BigInt("abcdef123456789", "hex")

loop 10
    x := x.pow(2)
    
msgbox % x.__string()  ; this is a really really huge number

ahk2-bigint's People

Contributors

infogulch avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.