String representation of the Int64 representation
jorgebay opened this issue · 5 comments
jorgebay commented
It would be nice to have the string representation of numbers bigger than Math.pow(2, 53)
integrated on this module.
deathcap commented
👍 The closest way to currently do this seems to be toOctetString()
, but it returns a string of hexadecimal digits; toString()
returning the decimal representation even for >2^53 (instead of Infinity) would be nice.
soulne4ny commented
Version 0.4.0:
$ node
> const Int64 = require( 'node-int64' );
> b = new Buffer([0xff, 0xee, 0xdd, 0xcc, 0xAA, 0xBB, 0x00, 0x99])
<Buffer ff ee dd cc aa bb 00 99>
> (new Int64( b )).toString(10);
'-4822678473342823'
> b = new Buffer([96, 0x8e, 0x9c, 0xc6, 0x83, 0xa5, 0x19, 0x56])
<Buffer 60 8e 9c c6 83 a5 19 56>
> (new Int64( b )).toString(10);
'Infinity'
liaozhongwu commented
Any update on this issue? I publish hex2decimal to solve this problem. Here is my PR #17
soulne4ny commented
.toSignedDecimalString()
does correct transformation.
Then it is quite strange toString()
can not do what it is supposed to do.
michielbdejong commented
If you want to convert between 8-byte buffers and decimal strings, you can also use https://github.com/q3boy/int64/pull/1/files