Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
what is difference between 0.0 and 0.00 and 0.0f and 0.000f?
Posted

No difference.You apparently need to lean about the syntax for literal and how floating-point data types work: http://en.wikipedia.org/wiki/Floating_point[^].

[EDIT]

The literal without "f" is implementation dependent in C++, can be double of float, but the ones with "f" mean single-precision floating-point literal. All values are identical and represent zero real number.

(Credit to the comment by Ron Beyer below.)

—SA
 
Share this answer
 
v6
Comments
Ron Beyer 5-Sep-13 1:48am    
Almost :) At least with MSVCPP compiler 0.0 is a double and 0.0f is a float. See this post. This is pretty compiler and platform specific so it doesn't behave the same way on all of them, it may be equal or different.
Sergey Alexandrovich Kryukov 5-Sep-13 1:57am    
Oops! I forgot it's C++ and used the .NET rule for floating-point, which is float type if no "f" or "d" postfix is used (I think double by default would be better). I fixed the answer and credited your comment. Thank you.
—SA
Ron Beyer 5-Sep-13 1:58am    
Almost there, even in .NET just typing 0.0 is a double, 0.0f is a float. Try it out (I just did to verify). I get an invalid cast error and a red underline when I write float f = 0.0;

Sergey Alexandrovich Kryukov 5-Sep-13 2:17am    
Oh bother, that's right; I messed up things. (After I saw this error for the first time, the idea to write without proper suffix never came to my mind.)
Thank you, I fixed again.
—SA
Ron Beyer 5-Sep-13 2:20am    
5'd for all the effort (despite getting my name wrong LOL)
i know... "0.0 and 0.00" means double Type
i know... "0.0f and 0.000f" means float Type

for example,
C++
float a = 0.0;   // float <= double
float b = 0.00;   // float <= double
double c = 0.0f;   // double <= float 
double d = 0.00f;   // double <= float 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900