Strange numbers like 3.1415f ...

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
nitroman

Strange numbers like 3.1415f ...

Post by nitroman »

In the examples, there is a lot of numbers that are used and I don't know what they mean...

for example:

Code: Select all

smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setFOV(3.1415f)
//etc, etc, etc...
why there is a "f" after 3.1415???

I use those numbers without knowing their meanings so I can't adjust them...

Can you give me explanations, I'm confused... :?
Fussel
Posts: 22
Joined: Fri Apr 09, 2004 1:47 pm

Post by Fussel »

its a float value..
depending on what you need you can take different types of numbers..for example int (1,2,3...) float, etc..dont know a good tutorial on this, but try a search with google
hearsedriver
Posts: 81
Joined: Fri Aug 22, 2003 12:06 pm
Location: Germany
Contact:

Post by hearsedriver »

This magic number is the constant PI, which is 180 degrees in radians. The f behind the number helps the compiler to distinguish 32-bit floats and 64-bit doubles. Because setFOV expects floats, and the compiler assumes 64-bit double for floating point constants without the "f", using the constant without the "f" would result in a compiler-warning that the precision will be lost when passing it to a function that uses floats.

HTH
Matt
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
nitroman

Post by nitroman »

Ok I understand. It wasn't so complicated. :wink:

so

camera->setFOV(3.1415f)

is the same thing as:

float myfloat= 3.1415
camera->setFOV(myfloat)


?
warui
Posts: 232
Joined: Wed Apr 14, 2004 12:06 pm
Location: Lodz, Poland
Contact:

Post by warui »

Yes. 'f' after the number forces compiler to treat it as a float value.
Tomasz Nowakowski
Openoko - www.openoko.pl
nitroman

Post by nitroman »

thanks :wink:
Post Reply