[racket] Possible bug with sine and cosine (simple floating-point issue?)

From: prad (prad at towardsfreedom.com)
Date: Thu Jan 6 23:51:49 EST 2011

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

Fixed-point arithmetic

Floating point representation

(there are no doubt better explanations, but this is what i found on
short notice).

in friendship,

Posted on the users mailing list.