hxArbitraryPrecisionInt

Platform independent arbitrary precision Int library for haxe based on Array. Unittests included.
https://github.com/Laguna1989/hxArbitraryPrecisionInt

To install, run:

haxelib install hxArbitraryPrecisionInt 1.0.0 

See using Haxelib in Haxelib documentation for more information.

README.md

hxArbitraryPrecisionInt

Platform independent arbitrary precision Int library for haxe based on Array. Unittests included.

ArbitraryPrecisionInt is a DataType which can be used for unsigned integers which can become arbitrary large. This class runs on flash, html5, neko and hxcpp and comes with basic arithmetics a set of unit tests. It is based on the binary representation of the number (stored as Array). The only limitation is the machines memory. Very large numbers might become slow.

Usage

This exmapels might seem kind of useless for small integer numbers but will work nevertheless for positive integer numbers of arbitray size.

var x : ArbitraryPrecisionInt = ArbitraryPrecisionInt.fromInt(15);
var y : ArbitraryPrecisionInt = ArbitraryPrecisionInt.fromInt(3);
var add : ArbitraryPrecisionInt = x.add(y); // 18
var sub : ArbitraryPrecisionInt = x.sub(y); // 12 
var mul : ArbitraryPrecisionInt = x.mul(y); // 45
var div : ArbitraryPrecisionInt = x.div(y); // 5
var log2 : Float = x.calcLog2(); // \approx 3.906
Contributors
Laguna
Version
1.0.0
Published
5 months ago
License
MIT

All libraries are free

Every month, more than thousand developers use haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on Github!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on Github