Skip to content

Why you should be careful about 'optimizations'

arcanis.github.com
5 pointsArcanis2 comments
On HN

Comments

> So 5.4 | 0 will gives 5, which is a flooring operation. However, -5.4 will give -5. And that’s a ceiling operation.

So, | is actually doing a round toward zero. It seems like the problem described is actually caused by simply misunderstanding what the floor function does (round toward negative infinity).

I sympathise, but doing bitwise operations on floating point values without care is just asking for it

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.