1.0f? I must be the only one...
Real number literals (like 1.5, 3.14159, 1.0, etc) are double precision. The compiler will have to perform a cast when assigning them to floats. You can make them floats by appending an f to the number.
quote:
Original post by Anonymous Poster
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...
In 3d graphics you don''t deal with pixels like you do with 2d graphics, so you can''t say that something 3d is equivalent to a certain number of pixels b/c if the field of view, viewing distance, camera position, screen resolution, etc. changes the number of pixels change. I won''t go into this because this is related more to understanding 3d.
In OpenGL functions (and Direct3D also) it''s usually the case that 1.0f represents a maximum value and 0.0f represents a minimum value, and you should use values between these numbers.
Digital Radiation
quote:
Original post by Wizardry
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.
Dont seem to get any errors when I dont... and still didnt when I moved up to warning level 4....
Not errors, warnings. It doesn''t happen every time, it often depends on the context. I think that it occurs most often with non-initialization assignment and the +=, -= etc operators and with some function calls. Still don''t get them, I don''t know what to tell you.
so how would u put it in a function to pass a variable to it?
like this
like this
|
You wouldn''t do it like that, but like this:
The f suffix (or F, it''s not case-sensitive) is used with literals, that is, values which you have provided as literal numerical values, without an identifier as a variable would have.
Harry.
|
The f suffix (or F, it''s not case-sensitive) is used with literals, that is, values which you have provided as literal numerical values, without an identifier as a variable would have.
Harry.
Harry.
quote:
Original post by jag_oes
... I just recently won a copy of Visual Studio 6.0 at a programming competition...
quote:
Original post by jag_oes
...Since I am new to programming and everything related to it (like compilers)...
Let me get this straight, you won a copy of MSVC6 at a programming competition but you are new to programming ?? How did you win the competition then?
Sounds a bit sus to me
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement