New issue 1100 by erights: Deprecate enforceNat. Replace with tests for
Int32 and UInt32
http://code.google.com/p/google-caja/issues/detail?id=1100
cajita.enforceNat is not used anywhere in our source tree. It dates from
before I understood JavaScript well, and makes the wrong distinction. It
should be deprecated and eventually retired.
All JavaScript numbers are actually IEEE double precision floating point
numbers. Defensive code often wants to either do reliable integer
arithmetic, or reliably fail if it can't. So enforceNat checks that a
number is within (approximately) the largest continuous range of
representable integers among these numbers -- which is about 53 bits of
precision.
When integers are needed with JavaScript itself, for example, in the
semantics of arrays, the two subranges used are Int32 and UInt32. These can
be tested respectively by
x === x >> 0
and
x === x >>> 0
Since precision unlimited integers are unavailable, when a reliable integer
is needed, one of these two tests should be used.
If you have a use for integers larger than 32 but not larger than 53,
please speak up before we deprecate...
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
Comment #1 on issue 1100 by erights: Deprecate enforceNat. Replace with
tests for Int32 and UInt32
http://code.google.com/p/google-caja/issues/detail?id=1100
(No comment was entered for this change.)