'Assigning BigInt stores wrong number (number+1)

I want to define a BigInt number in JavaScript. But when I assign it, the wrong number is stored. In fact 1 is added to the number when storing.

let num = BigInt(0b0000111111111111111111111111111111111111111111111111111111111111)
console.log(num)                // Output: 1152921504606846976n
console.log(num.toString(2))    // Output: 1000000000000000000000000000000000000000000000000000000000000

So the number stored is 1152921504606846976, but it should be 11529215046068469765. Why is that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source