"Dr John Stockton" <> wrote in message
news:...
<snip>
>ISTM that the FAQ should have something on when parseInt
>should not be used.
>
>AFAICS, the first two superfluously call for conversion to
>Number (the subtraction does that, if it is needed); and the
>second two should be Math.floor.
<snip>

Done. The notes I wrote for section 4.21 (actually a more general
discussion of type-converting with JavaScript) currently include the
paragraph:-
|parseInt is occasionally used as a means of turning a
|floating point number into an integer. It is very ill suited
|to that task because if its argument is of numeric type it
|will first be converted into a string and then parsed as a
|number, very inefficient. This can produce very wrong
|results with numbers such as 2e-200, for which the nearest
|integer is zero, but with which parseInt returns 2. For
|rounding numbers to integers one of Math.round, Math.ceil
|and Math.floor are preferable, and for a desired result
|that can be expressed as a 32 bit signed integer the
|bitwise operation described below might also suite.
(There are additional notes on how the parsing is done, etc. in the
section on parseFloat)
The bitwise operation mentioned is OR zero. Which truncates floating
point numbers to integers but might be well suited to the situation in
the preceding posted code as the output is expected to be screen
co-ordinates so a result restricted to a 32 bit signed integer would be
expected anyway and it is quicker to execute than Math.floor.
Richard.