←back to thread

631 points wojtczyk | 1 comments | | HN request time: 0.242s | source
Show context
rgovostes ◴[] No.41410786[source]
A friend doing homework for a university assignment, circa Leopard or Snow Leopard, noticed that Calculator produced negative values when raising a negative number to an even power.

The bug turned out to be in CFNumber, in Core Foundation. CFNumber does a lot of fiddly stuff at the bit level for performance, and one of their optimizations for exponentiation was incorrect. Somehow it was never found by tests or due to buggy behaviors it created in other apps, but by someone clicking buttons and thinking critically about the output.

replies(5): >>41410865 #>>41411004 #>>41411294 #>>41411316 #>>41412437 #
1. zelphirkalt ◴[] No.41411316[source]
Maybe they never had proper tests. Something as simple as exponentiating,which is a basic functionality of any modern calculator, not working for 50% of all integers? That looks to me like no one ever really tested that stuff.