3 ms·
Though I'm sure you'd rather avoid it, you can inspect other bignum implementations and perform a port. Coming from a Java library, for example, the port would
by niftich 10y ago
Though I'm sure you'd rather avoid it, you can inspect other bignum implementations and perform a port. Coming from a Java library, for example, the port would be relatively straightforward, as syntax and semantics will largely match.
The most unpleasant thing is that JS doesn't have native ints, so you'll have to either use some other type as backing storage, and/or clever type coercion trickery, like what you see in asm.js.
[1] apfloat: http://grepcode.com/snapshot/repo1.maven.org/maven2/org.apfloat/apfloat/1.8.2/ http://grepcode.com/snapshot/repo1.maven.org/maven2/org.apfl...
[2] JDK's BigDecimal: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/java/math/BigDecimal.java#BigDecimal http://grepcode.com/file/repository.grepcode.com/java/root/j...
- valera_rozuvan 10y agoI am also considering Python-based "mpmath" [1], and C-based "Gnu Mpc" [2] as candidates for porting to JavaScript. [1] http://mpmath.org/ http://mpmath.org/ [2] http://www.multiprecision.org/ http://www.multiprecision.org/