Closed dadepo closed 7 years ago
So I have this binary string
let binaryString = 100000000000010000110110111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
Which I converted to bigInteger in base 2 like this:
let bigInteger = bigInt(num, 2)
When I now do bigInteger.toString() I was expecting 42540766411282592856903984951653826560' but I got42540766411282592856903984951653826561`
bigInteger.toString()
42540766411282592856903984951653826560' but I got
That is, the value is wrong by being one more than the value expected.
Also if I convert it to hexa string, the value is also off by 1.
That is when I do bigInteger.toString(16), I was expecting to get 20010db8000000000000000000000000 but got 20010db8000000000000000000000001
bigInteger.toString(16)
20010db8000000000000000000000000
20010db8000000000000000000000001
Is this a bug? Or I am the one doing something wrong? Thanks!
I guess you figured out the issue already?
Yup. I did. It was an error somewhere else which made me have the wrong expectation. Apologies for the trouble :)
So I have this binary string
let binaryString = 100000000000010000110110111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
Which I converted to bigInteger in base 2 like this:
let bigInteger = bigInt(num, 2)
When I now do
bigInteger.toString()
I was expecting42540766411282592856903984951653826560' but I got
42540766411282592856903984951653826561`That is, the value is wrong by being one more than the value expected.
Also if I convert it to hexa string, the value is also off by 1.
That is when I do
bigInteger.toString(16)
, I was expecting to get20010db8000000000000000000000000
but got20010db8000000000000000000000001
Is this a bug? Or I am the one doing something wrong? Thanks!