logoalt Hacker News

zipy124yesterday at 3:11 PM1 replyview on HN

Technically there is a closed form solution as long as the answer is less than 2^24 for a float32 or 2^53 for a float64, since below those all integers can be represented fully by a floating point number, and integer addition even with floating point numbers is identical if the result is below those caps. I doubt a compiler would catch that one, but it technically could do the optimisation and have the exact same bit answer. If result was intialised to a non-integer number this would not be true however of course.


Replies

bayesnetyesterday at 3:23 PM

A very good point! I didn’t think of that.