Javascript types
2009-05-27 23:21:08
Javascript has won the language wars, and look what we've got. A single Number
type (hooray), which is internally represented by a 64-bit IEEE float (erm, ok)
unless you're doing bitwise operations, in which case it's:
- violently coerced to a 32-bit signed integer in JS <= 1.1 (NaN if out of
range)
- silently coerced to a 32-bit signed integer in JS > 1.1 (truncated
fractional and high bits)
What have we done to deserve this?
(Disclaimer: I haven't been bitten by this design decision of doom, because I
don't do any Javascript programming. But I find myself strangely compelled not
to even bother, given the risks apparent).
Austin writes:
I would argue against the goodness of a single Number type. There needs to be at least two; an integral type and a real/floating type.