Division by zero on Alpha hardware

Report bugs, bug fixes and workarounds here.
Topic author
zoop
Posts: 2
Joined: 09.09.2003
With us: 21 years 2 months

Division by zero on Alpha hardware

Post #1by zoop » 10.09.2003, 22:58

Hi!

I have a bug report here:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=146305
and I think the bug is still present in 1.3.0.

The problem lies in celmath/vecmath.h:
template<class T> void Vector3<T>::normalize()
{
T s = 1 / (T) sqrt(x * x + y * y + z * z);
x *= s;
y *= s;
z *= s;
}

The division by zero obviously arises for x=y=z=0.

Alpha Hardware is not IEEE compatible thus dividing by zero does not yield "inf" but results in a Floating Point Exception which kills celestia.

I don't know what you expect to happen when you call normalize on a zero vector but it should probably be checked against beforehand.

The other alternative (if you really expect <0,0,0> to be "normalized" to <inf,inf,inf>) is to include the -mieee flag for gcc at least on the Alpha architecture. But that would mean a performance penalty for Alpha users.

Mika

Return to “Bugs”