1.0f? I must be the only one...
I am *really* new to programming but I have been able to look through many sources and understand what is going on. The one thing I cannot seem to understand is when someone has a number with an "f" after it. Like 1.0f or 1.5f...what does that mean? I have looked everywhere and cannot seem to find the answer.
Thanks.
It stands for "float". Any number with a ''f'' after it is considered to be a floating point number by the compiler.
As far as I know, the same goes for the other data types. ''d'' for "double", and so on. if anyone would like to correct me on this, please do.
/**************************************
* Hookt on Fonix relly werked fer mee!
* WarAmp
***************************************/
As far as I know, the same goes for the other data types. ''d'' for "double", and so on. if anyone would like to correct me on this, please do.
/**************************************
* Hookt on Fonix relly werked fer mee!
* WarAmp
***************************************/
Waramp.Before you insult a man, walk a mile in his shoes.That way, when you do insult him, you'll be a mile away, and you'll have his shoes.
I knew why they were there, but 1 question... do they make *any* difference? I mean, wont the compiler optimize it for you even if you dont put them there... its pretty obvious that it''d be a waste to use a double value for it...
February 27, 2001 09:40 PM
optimize? That sounds horrible. The compiler should never be allowed to change how your code works. Sure it should be allowed to do whatever it wants as long as it has no effect on the outcome, but things like precision should not be touched. He''s probably using java, where double is the default precision.
Yes, the f does serve a purpose. It ensures that the compiler knows that the number is meant to be a float. Decimal numbers omiting the f suffix are considered doubles by default. If you were to attempt to compile the code without the f suffix, you would recive about a million warning messages about conversion from const double to float, possible loss of data. You could leave it off if you wanted to, but it would make your code much harder to debug.
Ok, thanks for the extremely fast answers. Now a few more questions.
I have been in a CS class for a semester or so and it is moving really slow. I wanted to start messing around with different things mainly to do with graphics. But we Turbo C++ 3.0 which I am sick of. On top of that I only have the crappy BGI graphic libraries to mess with.
In any case I just recently won a copy of Visual Studio 6.0 at a programming competition so I started reading those OpenGL tutorials that NeHe has. In the tutorial he would have something like this:
glTranslatef(-1.5f,0.0f,-6.0f);
When I messed with those numbers (just a little) I got completely different results so I was thinking maybe the "f" meant the number was being multiplied by a power of ten or something. I see that it means to specify a floating point but would anyone happen to know what "units" those arguements are in?
I know that question should be asked in one of the specified forums but there is no point in opening a new thread eh?
Thanks for the help.
p.s. Since I am new to programming and everything related to it (like compilers), is VS 6.0 supposed to be good? Just wondering...
I have been in a CS class for a semester or so and it is moving really slow. I wanted to start messing around with different things mainly to do with graphics. But we Turbo C++ 3.0 which I am sick of. On top of that I only have the crappy BGI graphic libraries to mess with.
In any case I just recently won a copy of Visual Studio 6.0 at a programming competition so I started reading those OpenGL tutorials that NeHe has. In the tutorial he would have something like this:
glTranslatef(-1.5f,0.0f,-6.0f);
When I messed with those numbers (just a little) I got completely different results so I was thinking maybe the "f" meant the number was being multiplied by a power of ten or something. I see that it means to specify a floating point but would anyone happen to know what "units" those arguements are in?
I know that question should be asked in one of the specified forums but there is no point in opening a new thread eh?
Thanks for the help.
p.s. Since I am new to programming and everything related to it (like compilers), is VS 6.0 supposed to be good? Just wondering...
Float (in a 32 bit compiler):
Size: 32 bit, 4 Byte
Data Range: 3.4 ^ 10-38 to 1.7 ^ 1038
Usage: Scientific (7-digit) precision)
See this for more information on IEEE standards than you every wanted.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
Size: 32 bit, 4 Byte
Data Range: 3.4 ^ 10-38 to 1.7 ^ 1038
Usage: Scientific (7-digit) precision)
See this for more information on IEEE standards than you every wanted.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said
![Resist Windows XP''s Invasive Production Activation Technology!](http://www.crosswinds.net/~druidgames/resist.jpg)
http://www.gdarchive.net/druidgames/
The "units" of OpenGL are whatever you want them to be. As long as you use the same scale consistently throughout your code. You could make 1 OpenGL unit represent any thing from 1 Mile in your Game World to 1 Micrometer. It''s entirely up to you. In my engine, I let them represent Meters, so that if I wanted to move at 3 Meters/Sec (Normal Walking speed) I just add (3 * # of Milliseconds to render the frame) and that will let me move at 3 Meters/Sec consistently throughout my world.
Hope that helps...
/**************************************
* Hookt on Fonix relly werked fer mee!
* WarAmp
***************************************/
Hope that helps...
/**************************************
* Hookt on Fonix relly werked fer mee!
* WarAmp
***************************************/
Waramp.Before you insult a man, walk a mile in his shoes.That way, when you do insult him, you'll be a mile away, and you'll have his shoes.
February 28, 2001 02:29 PM
Ok...maybe "units" was the wrong word to use. I meant many pixels would "1.0f" be? I changed some numbers around by small amounts and the result was a huge difference. It seems like "1.0f" is the equivalent to about 50px or so but I''m not sure...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement