peterolson / biginteger.js Goto Github PK
View Code? Open in Web Editor NEWAn arbitrary length integer library for Javascript
License: The Unlicense
An arbitrary length integer library for Javascript
License: The Unlicense
I noticed when using bigInt() that I get different results at some point when comparing math done on bitInt()s that use toString() to calculate the (correct) value and simply adding an empty string (incorrect).
You can see the issue in the console with the data set at https://jsfiddle.net/6nj92xqs/
I try to use toString()
with radix>36
using BigInteger.min.js
and I suspect an bug there.
Next code
for(var i=0;i<256;i++) {
var big = bigInt(i);
console.log(i + '="' + big.toString(40) + '"');
}
Will show this
33="x"
34="y"
35="z"
36=""
37="<37>"
38="<38>"
39="<39>"
36 is empty string.
bigInt('36').toString(40) === ''; //true
bigInt('36').toString(40) === bigInt('1476').toString(40); //true
bigInt('1476').toString(40) === bigInt('59076').toString(40); //true
bigInt('59076').toString(40) === bigInt('2363076').toString(40); //true
Looks like bug.
Is there some specific reason why square root method isn't implemented?
I was wondering if you could add adding built-in secure random number generation. Possibly using window.crypto.getRandomValues for browsers and require('crypto') for node.js. Thanks!
Hi,
I need to check if given variable is instance of BigInteger.
I guess right now its impossible to do it in "nice" way because BigInteger is "hidden" via fnReturn.
Right now i'm doing the following: bigInt('1234') instanceof bigInt().constructor
but it's not very elegant to create BigInteger object to perform the check
If we could add at least:
fnReturn.isInstance = function(val) { return val instanceof BigInteger};
this way one could perform the check
Thanks
On http://peterolson.github.com/BigInteger.js/Test.htm (with chrome) I get:
...
0 = -0: Failed
...
For example, if you do something like this:
var a = bigInt(2).pow(1000000).minus(1);
document.write(a.toString());
The printed result is:
If you go towards the bottom there's actual numbers, but it starts off with that mess. What's going on here?
var test = bigInt("1433277717218013232");
test.add(1);
console.log(test.toString());
result same as original .
Is shiftRight logical or arithmetical?
Test case:
var a = bigInt("14930352");
a.minus(9227465);
return a.equals("14930352");
Should return true, returns false.
> bigInt("10000000010000000").subtract(bigInt("10000000")).toString()
< "100000000010000000"
Line 191 in 73d1188
It seems conditions are wrong.
Hi Peter, are there any plans to implement bitwise operations?
Can we have a bower package for this please <3
The modInv function is implemented using Extended Euclidean Algorithm, which is a straightforward function, but does behave normally, even if this
is not co-prime to the modulus n
. In such a case, the resulting t
is not a proper inversion modulo, as such number does not exist (i.e. there is no number t
s.t. t*a - k*n = 1
for any k).
In order to address the issue, implementations usually check during the algorithm whether gcd(this,n) == 1
by checking the value of r
, as it indicates the gcd
in EEA.
The easy, one-liner fix for the issue is to check it as well:
if(!r.equals(1)) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime");
The line shall be added anywhere between the end of the while
loop and the return t
statement.
Hi there! I notice there's no log()
function in the docs. is it possible to get a natural log on a bigInt instance?
A modular inverse function could be a good addons for cryptographic applications
Here one sample code inspired from C sample in http://rosettacode.org/wiki/Modular_inverse
function _invmod( a, n ) {
var t = bigInt('0'); var nt = bigInt('1');
var r = n; var nr = a.mod(n);
var tmp;
while (! nr.isZero() ) {
var quot = r.divide(nr);
tmp = nt; nt = t.subtract(quot.multiply(nt)); t = tmp;
tmp = nr; nr = r.subtract(quot.multiply(nr)); r = tmp;
};
if ( r.greater(1) ) return bigInt(0);
if ( t.isNegative() ) t = t.add(n);
return t;
}
I'm trying to do operations in 160 bit integers using the bigInteger.js library, but I want to keep a representation of those in hex format so I can transmit them over and use them as ID.
var git_sha1 = require('git-sha1');
var bigInt = require("big-integer");
var uuid = git_sha1((~~(Math.random() * 1e9)).toString(36) + Date.now());
console.log('in hex \t', uuid); // See the uuid I have
console.log('in dec \t', bigInt(uuid, 16).toString()); // convert it to bigInt and then represent it as a string
console.log('to hex \t', bigInt(uuid, 16).toString(16)); // try to convert it back to hex
Here is my output:
in hex 4044654fce69424a651af2825b37124c25094658
in dec 366900685503779409298642816707647664013657589336
to hex 366900685503779409298642816707647664013657589336
I need that to hex
to be the same as in hex
. I also opened this question here: http://stackoverflow.com/questions/26258377/convert-a-decimal-number-represented-as-a-string-to-its-hex-format-still-represe and will post here the answer if I get lucky. Thank you!
> a = bigInt("1444051800000000000", 10)
> a.toString()
< "1444051800000000000"
> a = a.subtract(bigInt(34200).multiply(1e9))
> a.toString()
< "14440176000010000000"
> a.subtract(0).toString()
< "14440176000110000000"
Is there any want to do the equivalent of a Math.exp()
for bigInt?
I would try bigInt(Math.E).pow(2000)
or similar but bigInt obviously only handles ints, not floats.
Thanks for any advice!
Try this:
bigInt.randBetween(0,"11703780079612452")
Around half of the times, you'll get undefined
. Otherwise it works fine.
If you do this:
bigInt.randBetween(1,"11703780079612452")
It's the same thing but instead of undefined you get ones.
I didn't thoroughly test other values, although I've been using it apparently flawlessly in other conditions where I would use other ranges. The result is the same whether I give the range a bigInt object or a String.
I'm writing a simple calculator tool using BigInteger.js.
But I got an error. Apparently, an error has occurred in the shiftRight
method.
Chrome's log attached below.
> bigInt("-1").shiftRight(24)
SmallInteger {value: -1, sign: true, isSmall: true}
> bigInt("-1").shiftRight(25)
BigInteger.js:843 Uncaught TypeError: Cannot read property 'prev' of undefined
at SmallInteger.BigInteger.shiftRight (BigInteger.js:843:63)
at <anonymous>:2:14
at Object.InjectedScript._evaluateOn (<anonymous>:895:140)
at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)
at Object.InjectedScript.evaluate (<anonymous>:694:21)BigInteger.shiftRight @ BigInteger.js:843(anonymous function) @ VM4996:2InjectedScript._evaluateOn @ VM4881:895InjectedScript._evaluateAndWrap @ VM4881:828InjectedScript.evaluate @ VM4881:694
Hi Peter, I really want to thank you for this fantastic library!
For a while I wanted to implement something similar for Haxe and I tried several times. After a few failures I decided to "ad(a|o)pt" your code and now it works perfectly. The code is here:
https://github.com/fponticelli/thx.core/blob/master/src/thx/BigInt.hx
https://github.com/fponticelli/thx.core/tree/master/src/thx/bigint
The most notable aspect of this port is that it works on JS, CPP, C#, Java, Flash, Neko, PHP and Python. I just wanted to share my gratitude.
BigInteger seems to have troubles with zeros (on toString or probably even on internal object representation). See additional testcases in https://github.com/leobuettiker/BigInteger.js/blob/master/BigInteger.test.js
Would be awesome if input number could be given as a hex string.
e.g 4ffeebdab4549898d9ef89eb98a8
seems, if (isPrecise(a + BASE)) {
is incorrect, it should look like: if (isPrecise(Math.abs(a) + BASE)) {
https://github.com/peterolson/BigInteger.js/blob/master/BigInteger.js#L138
I think, it is better to make addSmall
applicable with any carry within [0; MAX_INT)
e.g. bigInt(64).root(3) // 4
.
One would think that "pow" would be enough (inverting the radix), but actually no, because bigInt(64).root(1/3) // 3
, I assume because of rounding error since bigInt(64).pow(1/3 + 0.0000000000000001) // 4
Hi,
I'm porting a SRP library to support biginteger, but I've detected an error in the modPow method.
There is bit of code that reproduces the error.
'use strict';
var bigInt = require('big-integer');
var bignum = require('bignum');
function h(s) {
return bigInt(s.split(/\s/).join(''), 16);
}
var test = [
{
g: h('02'),
x: h('b5200337cc 3f3f926cdd dae0b2d310 29c069936a 844aff5877' +
'9a545be89d 0abe'),
N: h('ac6bdb4132 4a9a9bf166 de5e138958 2faf72b665 1987ee07fc' +
'3192943db5 6050a37329 cbb4a099ed 8193e07577 67a13dd523' +
'12ab4b0331 0dcd7f48a9 da04fd50e8 083969edb7 67b0cf6095' +
'179a163ab3 661a05fbd5 faaae82918 a9962f0b93 b855f97993' +
'ec975eeaa8 0d740adbf4 ff747359d0 41d5c33ea7 1d281e446b' +
'14773bca97 b43a23fb80 1676bd207a 436c6481f1 d2b9078717' +
'461a5b9d32 e688f87748 544523b524 b0d57d5ea7 7a2775d2ec' +
'fa032cfbdb f52fb37861 60279004e5 7ae6af874e 7303ce5329' +
'9ccc041c7b c308d82a56 98f3a8d0c3 8271ae35f8 e9dbfbb694' +
'b5c803d89f 7ae435de23 6d525f5475 9b65e372fc d68ef20fa7' +
'111f9e4aff 73'),
k: h('5b9e8ef059 c6b32ea59f c1d322d37f 04aa30bae5 aa9003b832' +
'1e21ddb04e 300'),
a: h('f200000000 0000000000 0000000000 0000000000 0000000000' +
'0000000000 0000000000 0000000000 0000000000 0000000000' +
'0000000000 0000000000 0000000000 0000000000 0000000000' +
'0000000000 0000000000 0000000000 0000000000 0000000000' +
'0000000000 0000000000 0000000000 0000000000 0000000000' +
'0000000000 0000000000 0000000000 0000000000 0000000000' +
'0000000000 0000000000 0000000000 0000000000 0000000000' +
'0000000000 0000000000 0000000000 0000000000 0000000000' +
'0000000000 0000000000 0000000000 0000000000 0000000000' +
'0000000000 0000000000 0000000000 0000000000 0000000000' +
'000000d3d7'),
u: h('b284aa1064 e8775150da 6b5e2147b4 7ca7df505b ed94a6f4bb' +
'2ad873332a d732'),
B: h('22ce5a7b9d 81277172ca a20b0f1efb 4643b3becc 5356647395' +
'9b07b790d3 c3f08650d5 531c19ad30 ebb67bdb48 1d1d9cf61b' +
'f272f84398 48fdda58a4 e6abc5abb2 ac496da509 8d5cbf90e2' +
'9b4b110e4e 2c033c70af 73925fa374 57ee13ea3e 8fde4ab516' +
'dff1c2ae8e 57a6b264fb 9db637eeea e9b5e43dfa ba9b329d3b' +
'8770ce8988 8709e02627 0e474eef82 2436e63975 62f2847786' +
'73a1a7bc12 b6883d1c21 fbc27ffb3d beb85efda2 79a69a1941' +
'4969113f10 451603065f 0a01266664 5651dde44a 52f4d8de11' +
'3e2131321d f1bf4369d2 585364f9e5 36c39a4dce 33221be57d' +
'50ddccb438 4e3612bbfd 03a268a36e 4f7e01de65 1401e108cc' +
'247db50392'),
e: h('92aaf0f527 906aa5e860 1f5d707907 a03137e1b6 01e04b5a1d' +
'eb02a981f4 be037b3982 9a27dba50f 1b27545ff2 e28729c2b7' +
'9dcbdd32c9 d6b20d340a ffab91a626 a8075806c2 6fe39df91d' +
'0ad979f9b2 ee8aad1bc7 83e7097407 b63bfe58d9 118b9b0b2a' +
'7c5c4cdeba f8e9a460f4 bf6247b0da 34b760a59f ac891757dd' +
'edcaf08eed 823b090586 c63009b2d7 40cc9f5397 be89a2c32c' +
'dcfe6d6251 ce11e44e6e cbdd9b6d93 f30e90896d 2527564c7e' +
'b9ff70aa91 acc0bac174 0a11cd184f fb989554ab 58117c2196' +
'b353d70c35 6160100ef5 f4c28d19f6 e59ea2508e 8e8aac6001' +
'497c27f362 edbafb25e0 f045bfdf9f b02db9c908 f10340a639' +
'fe84c31b27')
}
]
test.forEach(function(o, i, a) {
// Starting the test with bigInt()
var bi_step1 = o.g.modPow(o.x, o.N);
var bi_step2 = o.B.subtract(o.k.multiply(o.g.modPow(o.x, o.N)));
var bi_step3 = o.a.add(o.u.multiply(o.x));
var bi_step4 = bi_step2.modPow(bi_step3, o.N);
// Now with bignum !
// Converting the numbers to bignum() from bigInt()
var bn_g = bignum(o.g.toString(16), 16);
var bn_x = bignum(o.x.toString(16), 16);
var bn_k = bignum(o.k.toString(16), 16);
var bn_a = bignum(o.a.toString(16), 16)
var bn_u = bignum(o.u.toString(16), 16)
var bn_B = bignum(o.B.toString(16), 16);
var bn_N = bignum(o.N.toString(16), 16);
var bn_step1 = bn_g.powm(bn_x, bn_N);
var bn_step2 = bn_B.sub(bn_k.mul(bn_g.powm(bn_x, bn_N)));
var bn_step3 = bn_a.add(bn_u.mul(bn_x))
var bn_step4 = bn_step2.powm(bn_step3, bn_N)
// Comparing the results
if(bn_step4.toString(16) != bi_step4.toString(16)) {
console.log();
console.log("Step 4 result doesn't match !!!");
console.log();
console.log(" bigInt step4");
console.log("--------------");
console.log(bi_step4.toString(16));
console.log();
console.log(" bignum step4");
console.log("--------------");
console.log(bn_step4.toString(16));
console.log();
console.log(" expected step4");
console.log("----------------");
console.log(o.e.toString(16));
console.log();
}
});
Best regards,
Zarmack
console.log(bi(0).multiply(-1).toString())
prints "-0"
must be "0"
I am using an http API which response type is ArrayBuffer . so i am using Dataview to read int from it. now javascript support 32 bit int which is 4-byte. cane i initiate big integer with data view specifying startingOffset and length ?
bigint = require('big-integer');
bigint(Number.MAX_VALUE);
fails with
Error: Invalid integer: 1.797693134862315700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
at parseInput (/tmp/node_modules/big-integer/BigInteger.js:557:29)
at fnReturn (/tmp/node_modules/big-integer/BigInteger.js:644:16)
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
likewise
bigint = require('big-integer');
bigint(Number.MAX_VALUE.toString());
fails with
Error: Invalid integer: 1.797693134862315700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
at parseInput (/tmp/node_modules/big-integer/BigInteger.js:557:29)
at fnReturn (/tmp/node_modules/big-integer/BigInteger.js:644:16)
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.emit (events.js:95:17)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
Hey Peter,
I currently use big-rational which depends on 1.1.x of this library, and npm is saying that 1.1.7 is the latest version. However, it looks like the latest version is 1.1.6 or even 1.1.5. So getting the 1.1.7 tarball is resulting in a 404. Can you take a look?
Thanks,
Andy
I want to create a constructor for bigInt that can create a bigInt using a json object.
Example:
var jsonBigInt = {"value":[7588586,5407200,7027551,7871450,1855203,3483287,9891367,4339628,2206445,5226736,1375322,864086,9981035,28975],"sign":false,"isSmall":false}
var theBigInt = bigInt(jsonBigInt);
console.log(theBigInt.minus(1).mod(2));
Desired outcome for example code above:
'0' is printed to the console log.
If I have time then I will create this and then commit my changes to the repository.
This library is amazing! Keep up the amazing work.
In Java, to manipulate a textual string (for example for RSA) you would convert the string to bytes, construct a new BigInteger with the bytes and then do modPow(...)
. The result would be the encrypted string.
This however does not work with this library. Could this feature be added?
My javascript equivalent test (with BigInteger.min.js version 3bd64ef):
var test = "bla";
var bytes = [];
for (var i = 0; i < test.length; i++) {
bytes.push(test.charCodeAt(i));
}
var bInt = new bigInt(bytes);
console.log(bInt + ", " + bigInt.isInstance(bInt));
bInt.modPow(10, 100);
And this yields the following output (Firefox console):
[object Object], false
TypeError: bInt.modPow is not a function
Concluding that the constructor failed to create the object.
Hi there
I tried to use the randBetween function like this: bigInt.randBetween("1","2e64"). However get such error.
[app] TypeError: Cannot read property 'lesser' of undefined
< at min (///big-integer/BigInteger.js:913:17)
< at Function.randBetween (//node_modules/big-integer/BigInteger.js:945:19)
Is there anything wrong when I try to call this function. Please help to solve this problem.
Thanks,
I import the big-integer into a typescript's project. with d.ts from:
* https://github.com/borisyankov/DefinitelyTyped*
with the directive:
import * as bigInt from 'big-integer';
when call the function: bigInt like this:
let biTest = bigInt('12345', 16);
it's failed with error:
ORIGINAL EXCEPTION: TypeError: bigInt is not a function
there are the logs when i try to output it:
console.log(typeof bigInt) ==> Object
console.log(bigInt) => Object {0: SmallInteger, 1: SmallInteger, 2: SmallIntege....}
so. what's wrong ?
On this line:
Line 1120 in 90508a2
text.join("e")
will produce TypeError instead of the correct exception, because text
is undefined
(it is assigned later).
20^2010 mod 564782141 = 537103799(I hope so) but I am getting 536569496.
It may be I have not read the limitations of bigInteger.js very well but if it does not work I cannot use it.
Observed problem starts after mod length >=9.
Again I am not even sure the trusted answer(537103799) which I have mentioned here is correct. But I have 2 answers from 2 sources.
Any help will be appreciated
+bigInt(1.11e30)
returns 1.11e+29
. It should return 1.11e+30
.
Just updated to 1.5.1.
This may or may not be the right place to report this issue, but I'm in good faith that you can, at least, forward this to the appropriate place. While testing Peter Norvig's Beal-counterexample-checker, I observed some bad behavior for certain near-counterexamples like 388288^3 + 18201^4 = 552097^3
:
A and B have the common factor 6067
. The checker is right about this. I said near-counterexample.A ** x + B ** y is 168285292446216670 and C ** z is 9.290980510367889e+22 but they must be equal.
This is wrong, since equality does hold. This is the reason I'm reporting this issue.I believe this is a bug in or misuse of the underlying BigInt-implementation, which seems to live in this repository.
Note that this strangely doesn't happen for "more evil" near-counterexamples, e.g. 940463^3 + 31701^4 = 1225772^3
, which only have gcd 10567, which is a prime. But I digress :)
I was implementing a Fibonacci sequence and I noticed it was giving an incorrect 36'th term; 4930352 instead of 14930352. Here is example code to replicate the problem.
var bigInt = require('big-integer');
var number = bigInt(1);
var last = bigInt(1);
for(i=0;i<50;i++){
number = number.add(last);
last = number.minus(last);
console.log(number.toString());
}
As JoeClacks suggested on StackOverflow using a temporary variable in the for loop alleviates the problem perhaps this could be a hint to where the bug originates?
console.log(bigInt(100).pow(56).toString(),bigInt(100).pow(63).toString(),bigInt(100).pow(70).toString(),bigInt(100).pow(77).toString(),bigInt(100).pow(84).toString(),bigInt(100).pow(91).toString(),bigInt(100).pow(98).toString());
prints 0,0,0,0,0,0,0
for other powers of 100, such as 100 pow 50, 100 pow 99, etc getting the right answer. Is this a bug or am I missing something?
the following code will reproduce the problem: (note this code does not cause version 1.2.12 to fail)
var bigInt = require("big-integer");
var bigRat = require("big-rational");
var biMinA = bigRat( 1392508928 );
var biMaxA = bigRat( 2080374784 );
var biMinB = bigRat( 0 );
var biMaxB = bigRat( 15668040695808 );
var maxOfMins = biMinA.compare( biMinB ) > 0 ? biMinA : biMinB;
var minOfMaxs = biMaxA.compare( biMaxB ) < 0 ? biMaxA : biMaxB;
console.log( "evaluateRangeOverlaps(): maxOfMins: " + maxOfMins );
console.log( "evaluateRangeOverlaps(): minOfMaxs: " + minOfMaxs );
if( maxOfMins.compare( minOfMaxs ) < 0 ) {
//
// Essentially computing a fraction of overlap w/ respect
// to the overall spanned range of A & B.
//
var deltaNumerator = minOfMaxs.subtract( maxOfMins );
console.log( "deltaNumerator: " + deltaNumerator );
var maxOfMaxs = biMaxA.compare( biMaxB ) > 0 ? biMaxA : biMaxB;
var minOfMins = biMinA.compare( biMinB ) < 0 ? biMinA : biMinB;
//console.log( "minOfMins: " + minOfMins );
//console.log( "maxOfMaxs: " + maxOfMaxs );
var deltaDenominator = maxOfMaxs.subtract( minOfMins );
rangeOverlap = deltaNumerator.divide( deltaDenominator );
console.log( "ro: " + rangeOverlap );
}
I'm using this library for a hashing function, more precisely I'm using the xor and times functions within this library. However, precision seems to be an issue.
With this library:
-3750763034362895579 XOR 52 = -3750763034362895400
Correct answer:
-3750763034362895579 XOR 52 = -3750763034362895599
Hi,
The bower support, as requested in #78, works!
Unfortunately I am not able to specify a version number. This means I cannot use a "release" of big-integer but either have to build with the latest commit, which might mean my builds might unexpectedly break in the future, or depend on a git commit hash, which makes it difficult and error-prone to depend on the correct version.
While reading the bower docs (I'm not an expert on creating packages) it seems that all that is required is pushing semver git tags. Would it be possible to add a 1.6.17 git tag to the latest release and use git tags to tag future versions?
I would love to send you a pull request but I don't think one can make PRs for git tags. Please let me know if there is anything I can do to make this happen.
Thanks for all the great work on this library! ❤️
Regards,
Dennis
Philosophy of mathematics aside, I find comparisons against Infinity
and -Infinity
pretty useful, especially when initializing a cursor. Currently, this throws an error, but it'd be nice if it didn't:
123 < Infinity //=> true
bigInt(123).compare(Infinity) //=>
Error: Invalid integer: Infinity
at parseStringValue (./node_modules/big-integer/BigInteger.js:1116:33)
at parseNumberValue (./node_modules/big-integer/BigInteger.js:1130:20)
at parseValue (./node_modules/big-integer/BigInteger.js:1135:20)
at SmallInteger.compare (./node_modules/big-integer/BigInteger.js:654:17)
at repl:1:13
at REPLServer.defaultEval (repl.js:248:27)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:412:12)
at emitOne (events.js:82:20)
bigInt(12345).pow(3).pow(1/3)
works fine (or, better, bigInt(12345).pow(3).pow(1/3 + 0.0000001)
does, see previous issue).
But running bigInt(12345).pow(4).pow(1/4)
from the console makes Chrome incapable or answering any other command:
the console appears responsive but no answers come for it... May be a browser problem...
https://github.com/peterolson/BigInteger.js#notequalsnumber
Why is there "bigInt(6).next() => 7" in that? That's not related to notEquals...is it?
I am trying to implement the seeded PseudoRandom function from Java to JavaScript.
I've tested the XOR with two bigIntegers:
"-6931047708307681506" and
"25214903917"
The result should be
"-6931047723896018573" but is
"-6931047723896018575".
after that, I've changed the resulting bigInteger manually to the correct value for further testing.
I am ANDing the correct bigInteger with "281474976710655".
Then the result should be
"273577603885427" but is
"7897372825229"
I hope that is enough information for you to reproduce the bug...
Also, I am very certain that this IS a bug, because i've made the same calculations with javascript, java and by hand, and the results from the java- and by-hand calculations were the same.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.