POV-Ray : Newsgroups : povray.advanced-users : Numerical Precision : Re: Numerical Precision Server Time
4 Oct 2024 23:14:17 EDT (-0400)
  Re: Numerical Precision  
From: Tim Attwood
Date: 9 Sep 2007 17:50:35
Message: <46e46aab$1@news.povray.org>
> By the way, I may need a lecture on computer float representation and
> binaries ...

Floating point in computers means floating point binary.

You may be familiar with binary integers...
the first bit is one, the next two, the next four, then eight,
16, 32, 64 128 etc. So for example you could represent
the number three in binary as a byte  00000011

But binary fractions go 1/2, 1/4, 1/8, 1/16, etc
At some point the fraction repeats, but in a computer
it just gets truncated after some point.
So 1/3 ends up 0.01010101...
An interesting part of this is that any fraction that has a
denominator with a factor other than 2 repeats, and
therefore exhibits a small amount of error. You can
look at the actual floating point bits online.
http://www.h-schmidt.net/FloatApplet/IEEE754.html
There's one bit for the sign, 8 bits for the exponent,
and 23 bits for the numbers.

The easiest way to get better accuracy is to use integers
where you can.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.