June 27, 2024, 06:35:26 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


int()

Started by kryton9, August 16, 2006, 08:38:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kryton9

I want to use something like a normal int() function. Can't seem to get it to work.

I have a float vector and want to make it an int to check for this:

if ( int(cDir.z) < 0) do stuff here;

I read about using a u, but not sure how to do that in this case?

Ionic Wind Support Team

Don't need the INT in this case since you can test for 0.  Unless your really looking for -1 or less.

I did post a couple of functions in tips and tricks that do the same thing as INT did in IBasic.
Ionic Wind Support Team

Ionic Wind Support Team

Ionic Wind Support Team

kryton9

I test for zero but being a float when I make an adjustment it never seems to hit just 0 exactly and keeps rotating. Getting frustrated, going to work on seomthing else, maybe that will help and I can figure it all out. Thanks anyways.

Ionic Wind Support Team

When working with floating point numbers always use an epsilon value instead of an equality test for zero.

if(abs(a) < .0001)
    //close enough to zero

The epsilon range is your choice but in most calculations you will never end up with an exact equality from the FPU.
Ionic Wind Support Team