[ODE] Denormal Floating Values

Jon Watte hplus-ode at mindcontrol.org
Mon Mar 15 11:25:07 MST 2004


You don't need to do it after every calculation; you can do it to all the values for each object at the end of each step.

Thus, for position, orientation, forces, and velocity, snap close-to-denormal to 0.

Here's a trick to do it for float32 (you can do something similar for float64), which should work on all IEEE floating point CPUs that store floats in the same byte order as ints:

inline void NukeDenormal( float & f )
{
  if( !(*(unsigned int *)&f & 0x3e000000 ) {
    f = 0;
  }
}

Note that this nukes a few exponent steps BEFORE you go denormal -- you want this, so that the chance of getting to denormal is very small. Getting a few denormals during a single step isn't going to kill you, but continual denormals everywhere certainly will.

If you're running your own simulations for controllers and stuff, those values should also be nuked if they get close, at the start of each step.

However, quantization like this will introduce some numerical imprecision artifacts. You be the judge of how well you can tolerate these.

Cheers,

				/ h+

-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org]On Behalf Of Bodo
Pfeifer
Sent: Monday, March 15, 2004 10:34 AM
To: ode at q12.org
Subject: [ODE] Denormal Floating Values


Hi,

I have freezes with ODE on Pentium4 CPU's.

I think this is some sort of problem with denormal floating
values.

I tried to use _controlfp etc., but it didn't work.

Mh, I searched the web, but the only answer for this problem was to
introduce a very small value and to check all values against this
'threshold' to handle smaller values as zero.
But I think, inserting an "if (value < MIN_VALUE) value=0" after each
calculation in ODE isn't a clever + clean solution ..

Is there anyone who had this problem? and maybe solutions to this?

Thanks,
Bodo

_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode




More information about the ODE mailing list