Paul Khuong mostly on Lisp

rss feed

Mon, 15 Aug 2011

 

An issue nobody cares about

CL-USER> (values (truncate (ash 1 60) pi)) 
366986312910250176 
CL-USER> (values (truncate (+ 4 (ash 1 60)) pi)) 
366986312910250176

Obviously, it’s just another floating-point issue.

It’s also an extremely minor optimisation obstable: when only the first return value is needed, it can be faster to implement the division exactly with machine integers than to convert to FP, divide, and convert back to an integer. Unfortunately, doing so would be too exact: we would have different results for equivalent programs depending on the level of optimisation (or the constant-ness of the divisor).

Plus, who does that, or cares about that operation?

posted at: 15:55 | /Lisp | permalink

Made with PyBlosxom Contact me by email: pvk@pvk.ca.