Skip to content

Commit

Permalink
little fix of bitsize-macro IntUtil for haxe 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
maitag committed Feb 10, 2021
1 parent 5280bec commit 4d8cb4c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pure haxe implementation for [arbitrary-precision integer](https://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic)

This lib was designed and optimized for fast [Karatsuba](https://en.wikipedia.org/wiki/Karatsuba_algorithm) multiplicaton.
Works with haxe-version 3.4.4 and up. Tested on hashlink, cpp, neko and javascript targets.
Works with haxe-version 3.4.4 and up to 4.2. Tested on hashlink, cpp, neko and javascript targets.


## Installation
Expand All @@ -26,9 +26,11 @@ haxelib install hxp
haxelib run hxp --install-hxp-alias
```

then simple call `hxp test hl neko ...` or
then simple call `hxp test hl neko ...`, `hxp bench ...` or
`hxp help` into projectfolder to see more targetspecific options.

To add a new benchmark you only need to put a new .hx file into [benchmarks-folder](https://github.com/maitag/littleBigInt/tree/master/benchmarks).


## Synopsis

Expand Down Expand Up @@ -194,7 +196,7 @@ Let me know if something's mising ~^

## Todo

- `haxelib run` command for invoking hxp testscripts
- `haxelib run` command to invoke the hxp testscripts from libfolder
- fixing output with leading zeros
- optional exponential notation for decimals
- optional great letters for hexadecimal output
Expand Down
4 changes: 2 additions & 2 deletions haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"license": "MIT",
"tags": ["math", "arbitrary", "precision", "integer", "bigint"],
"description": "pure haxe implementation for arbitrary-precision integer",
"version": "0.1.2",
"version": "0.1.3",
"classPath": "src/",
"releasenote": "fixing multiplication and inc-/decrement, adding pi-benchmark",
"releasenote": "little fix of bitsize-macro IntUtil for haxe 4.2",
"contributors": ["maitag"],
"dependencies": {}
}
4 changes: 2 additions & 2 deletions src/IntUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IntUtil
else {
var bitsize = IntUtil._bitsize(($i:UInt) - 1, $v{maxBitsize >> 1}, $v{maxBitsize >> 1});
if (bitsize >= $v{maxBitsize})
throw('Error calculating nextPowerOfTwo: reaching maxBitSize of $maxBitsize');
throw("Error calculating nextPowerOfTwo: reaching maxBitSize of " + $v{maxBitsize});
1 << bitsize;
}
):UInt);
Expand All @@ -41,7 +41,7 @@ class IntUtil
// how to make "private"? (no access from bitsize and _bitsize itself!)
public static macro function _bitsize(i:haxe.macro.Expr, n:Int, delta:Int) {
if (delta == 0)
return macro throw('Error calculating intBitLength: ' + $i + ' has more bits than maxBitSize');
return macro throw('Error calculating intBitLength: ' + $i + ' has more bits than maxBitSize of ' + $v{MAX_BITSIZE});
else {
delta = delta >> 1;
return macro {
Expand Down

0 comments on commit 4d8cb4c

Please sign in to comment.