Open borisgontar opened 5 years ago
Interesting find.
JavaScript internally stores numbers as either 64-bit floats or 32-bit integers, depending on their value. Since -0
is only representable as a float, it fails the type-check that fromBits
performs which only accepts integers. Providing support for -0
would require additional type checks, comparisons, and casting, which frankly don't seem worth it, given how rare this edge-case is.
Agreed.
On Mon, Apr 20, 2020, 2:29 PM Joshua Wise, notifications@github.com wrote:
Interesting find.
JavaScript internally stores numbers as either 64-bit floats or 32-bit integers, depending on their value. Since -0 is only representable as a float, it fails the type-check that fromBits performs which only accepts integers. Providing support for -0 would require additional type checks, comparisons, and casting, which frankly don't seem worth it, given how rare this edge-case is.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JoshuaWise/integer/issues/14#issuecomment-616732204, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLQS5XTQIV2DGFS2UHKIYLRNSH7BANCNFSM4G23EE6Q .
The method Integer.fromBits does not accept javascript's minus zero the same way other methods do:
The problem might be caused by the word "arguement" :-)
And thanks a lot for the excellent module 'better-sqlite3'.