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

 From: Hugh Myers (hsmyers at gmail.com) Date: Thu Jan 6 23:57:36 EST 2011 Previous message: [racket] Possible bug with sine and cosine (simple floating-point issue?) Next message: [racket] Possible bug with sine and cosine (simple floating-point issue?) Messages sorted by: [date] [thread] [subject] [author]

```The classic paper is
http://docs.sun.com/source/806-3568/ncg_goldberg.html entitled What
every computer programmer/scientist should know about floating
point... I've been involved with computer math since math chips were a
new idea and came on S100 boards for 8-bit machines--- this paper
would have saved me a great deal of frustration had I had it available
to me in the long ago...

On Fri, Jan 7, 2011 at 4:51 AM, prad <prad at towardsfreedom.com> wrote:
> 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
>
> (there are no doubt better explanations, but this is what i found on
> short notice).
>
> --
> in friendship,