floating point oddity

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Seven
Posts: 1030
Joined: Mon Nov 14, 2005 2:03 pm

floating point oddity

Post by Seven »

setting up a physX3 application. when using this code I break at the first pass and the value of p.Y is = 1.98357329e-38.
since pos.Y =0, y = 0, cubescale.Y = 20, and offset = 0.02f I am not understanding the value of p.Y

all variables are float (f32)

Code: Select all

 
    irrObject* irrLevel::createObject_Pyramid(int id, vector3df pos, vector3df rot, vector3df scale, vector3df cubescale, float mass, stringc texturefilename)
    {
        vector3df p = pos;
        vector3df r(0, 0, 0);
        float offset = getPhysX3Manager()->getSkinWidth();
 
        float x, y, z;
        for (y = 0; y < scale.Y; y++)
        {
            p.Y = pos.Y + (y* (cubescale.Y + offset));
            for (x = 0; x < scale.X - y * 2; x++)
            {
                p.X = pos.X + x* (cubescale.X + offset);
                for (z = 0; z < scale.Z - y * 2; z++)
                {
                    p.Z = pos.Z + z* (cubescale.Z + offset);
                    createObject_Cube(id, p, r, cubescale, mass, texturefilename);
                }
            }
            pos.X += cubescale.X;
            pos.Z += cubescale.Z;
        }
 
        return NULL;
    }
 
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: floating point oddity

Post by hendu »

That number means 0.0000000... 38 zeroes... 198.... so it's almost zero.
Post Reply