[SDL] Flickering and division by zero in Windows
Tommy Hinks
tommy.hinks at gmail.com
Sun Feb 25 09:15:49 PST 2007
This will fail horribly in C, giving a NaN (Not a Number ) value.
In C++ the way to go is:
#include <climits>
float inf = std::numeric_limits<float>::max();
This gives the largest possibly representable float number. You could
use double instead and get an even larger number.
However, most times trying to actually represent infinity is a bad
idea. It's inherently a kind of glitch in mathematics, and even more
so in computers. Simply test if a denominator is zero and if so you
know that it is infinite. Use a bool or something to say that, not the
largest number you can possibly think of, it will only lead to grief.
Hope that helps.
/ Tommy
On 25/02/07, Andre de Leiradella <leiradella at bigfoot.com> wrote:
>
> > How would you express infinity in binary?
> >
> > Lilith
> >
> Using doubles (8-byte):
>
> +inf: 3f f0 00 00 00 00 00 00
> -inf: bf f0 00 00 00 00 00 00
>
> Or in C:
>
> pinf = 1.0 / 0.0;
> ninf = -1.0 / 0.0;
>
> Cheers,
>
> André
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
More information about the SDL
mailing list