Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How come some people append f to the end of variables?

Tags:

c++

In the tutorial I'm reading for OGRE3d here the programmer is constantly adding f at the end of any variable he initializes, like 200.00f or 0.00f so I decided to erase f and see if it compiles and it compiles just fine, what is the point of adding f at the end of the variable?

EDIT: So you're saying if I initialize a variable with 200.03 it won't initialize it as a floating point but if I were to do so with 200.03f it would? If not where does the f become useful then?

like image 993
user1958850 Avatar asked Oct 29 '25 03:10

user1958850


1 Answers

It's a way to specify that number has to be interpreted as a "float", not a "double" (which is the standard for C++ decimal numbers and uses up twice the memory).

This discussion could be of help:

http://www.cplusplus.com/forum/beginner/24483/

like image 148
Okarin Avatar answered Oct 31 '25 19:10

Okarin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!