Re:I'm a fucking webmaster (2016)
by layer8 on Monday May 09, 2022 @08:59AM
(#31313488)
`my_number & 1 == 0` works.
[ Parent
| on HN ]
Re:I'm a fucking webmaster (2016)
by c0wb0yc0d3r on Monday May 09, 2022 @09:10AM
(#31313577)
JavaScript does have bitwise operators. Something I was surprised by was that numbers are stored as 64 bit while all of the bitwise operators operate on 32 but numbers. This means that every operation results in a number conversion first.
Not just 64 bit. 64 bit floating point. You can't just get the "low bit". You need to take the exponent into account to figure out which bit of the mantissa to grab. It's intrinsically more computationally difficult than is-odd on a real integer.