[racket] Possible bug with sine and cosine (simple floating-point issue?)
Sam Griff <sgriff89 at gmail.com> writes:
> Granted it is a very small amount to be off by
>
the being off by a small amount is a result of the way floating point
numbers (decimal) are stored in the computer's memory (binary).
whereas integers are easy:
1 dec 0001 bin
5 dec 0101 bin
9 dec 1001 bin
stuff like 3.1416 require a more imaginative effort that will not be an
exact value. it'll be close enough for practical purpose, but no cigar.
the main advantage of floating point is that you have a much larger
range available to you admittedly at the expense of some precision.
here are some links if you want to explore this further:
Floating point - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/Floating_point
Fixed-point arithmetic
http://en.wikipedia.org/wiki/Fixed-point_arithmetic
Floating point representation
http://www.youtube.com/watch?v=t-8fMtUNX1A
(there are no doubt better explanations, but this is what i found on
short notice).
--
in friendship,
prad