Fixes and adds tests the incorrect binding of +Infinity, -Infinity, -0, and extremely-large number values, by only binding to INTEGER for values which satisfy (Number.isSafeInteger(value) && !Object.is(value, -0)), instead of (Math.floor(value) === value).
In order to be preserve -0, we have to bind it as a REAL instead of an INTEGER like +0. As far as I can tell, this should be harmless.
A change in behaviour to call out: integer number values more massive than MAX_SAFE_INTEGER which could fit into an INTEGER will now be stored as REAL instead of INTEGER. I could go either way on this, but settled with this because you're usually not supposed to be treating values larger than MAX_SAFE_INTEGER as integers, even if they happen to fall on integer values.
If you want to maintain them as INTEGER, I think you could change the condition to something like (Number.isFinite(value) && !Object.is(value, -0) && Math.floor(value) === value && -9_223_372_036_854_775_808 <= value && value <= 9_223_372_036_854_775_807) instead.
Closes #89
Fixes and adds tests the incorrect binding of
+Infinity
,-Infinity
,-0
, and extremely-largenumber
values, by only binding toINTEGER
for values which satisfy(Number.isSafeInteger(value) && !Object.is(value, -0))
, instead of(Math.floor(value) === value)
.In order to be preserve
-0
, we have to bind it as aREAL
instead of anINTEGER
like+0
. As far as I can tell, this should be harmless.A change in behaviour to call out: integer number values more massive than
MAX_SAFE_INTEGER
which could fit into anINTEGER
will now be stored asREAL
instead ofINTEGER
. I could go either way on this, but settled with this because you're usually not supposed to be treating values larger thanMAX_SAFE_INTEGER
as integers, even if they happen to fall on integer values.If you want to maintain them as
INTEGER
, I think you could change the condition to something like(Number.isFinite(value) && !Object.is(value, -0) && Math.floor(value) === value && -9_223_372_036_854_775_808 <= value && value <= 9_223_372_036_854_775_807)
instead.