-4

Is there any way to increase this number?

console.log(79753741930607500+1) // 79753741930607500
console.log(79753741930607499+3) // 79753741930607500

upd:

zip encrypt/decrypt functions use 64bit numbers:

keys[0] = 305419896;
keys[1] = 591751049;
keys[2] = 878082192;

this.update_keys=function(c){
    keys[0]=crc32.crc32(keys[0],c);
    keys[1]=(((keys[1]+(keys[0]&0xff))*0x08088405+1)& 0xffffffff) >>>0;
    keys[2] = crc32.crc32(keys[2], keys[1] >>> 24);
};

keys[1] intermediate calculation may be more 79753741930607500.

exists universal solution to nodejs and browsers can use 64bit integers?

askovpen
  • 2,438
  • 22
  • 37

1 Answers1

3

Since the question is tagged this is possible using the node-bigint module.

Install with

npm install bigint

Usage:

var bigint = require('bigint');

console.log(bigint('79753741930607500').add(3)); //<BigInt 79753741930607503>

Though do note, there's no way to keep it as an integer and it will be returned as a bigint string or you can convert it to a string with the method .toString(). If you do try and return it as an integer, you will lose precision or it will return infinity.

Ben Fortune
  • 31,623
  • 10
  • 79
  • 80