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).Matthew Marshall writes:
Javascript has its problems, but I think we're lucky it's as good as it is. (closures!) We very well could have been stuck with VBScript in the browser. MWMYour comment:
[description](http://url) for links;
lines are wrapped to 80 columns after link replacement;
no other markup recognised.
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.