After checking, note that OR truncates towards zero and
Math.floor towards minus infinity.
Yes that distinction does need to be noted, but positioning co-ordinates
will tend to be >= zero as well as restricted to the 32 bit range so the
bitwise operation seems well suited to that task.
A list of "Maths Tricks" might be useful, including such as
n = n & (n-1)
which I think clears the least 1 bit, and can be looped for
one-bit-counting. And, of course, the "default" operator.
I like that idea, there isn't really a context to put that type of
information into yet but there could be.
I'd not seen that DJW's .style.width had a trailing px.
ISTM that there's probably nothing better than parseInt.
For a width property on a style object there probably isn't, but an
interest in the display dimensions of an element might be better
initially directed at the offsetWidth/Height properties of the element
itself (where supported), which is a numeric pixel value to start with.
Is it guaranteed that the numeric part has no leading zero,
even if there is a leading zero in the source file?
A quick experiment with IE 6 has setting a style.width to "021px"
returning "21px" when read, but I doubt that it could be guaranteed that
values assigned as strings would be normalised and stripped of
superfluous leading zeros. I would be surprised to see leading zeros
added to the string read from a style property (at least for
non-floating point (e.g. with em units) values).
OTOH if parseInt is going to be used for this task it probably should
still be provided with the radix argument as even if the string can
reasonably be expected to be in an unambiguous decimal format it should
still be quicker to execute the function when it doesn't have to
consider interpreting the string with any other radix. It doesn't save
much work if it is the ECMAScript algorithm that is implemented but it
will still be able to skip a couple of steps.
ISTM that you've probably done enough already, by a large
margin, to justify a new release of the FAQ proper with an
added note simply linking to your own index of the relevant
branch of your WWW site tree; or to post such a note as a
weekly FU to the FAQ.
It is certainly getting close, though a new version should be presented
to the group for comment prior to updating the FAQ itself. And the notes
will be going on Jim's server in the long term.
Richard.