+ 2
Float or integer
0.0 is double or float. What about 0? is 0 an integer ? Is 0 a float?
4 Answers
+ 8
0.0
C/C++, Java, C#: double
Python, JavaScript: float
0
C/C++, Python, Java, C#: integer
JavaScript: float*
If you want to make 0.0 explicitly float instead of double in C/C++, Java, C# then use 0.0f.
If you want to make 0 explicitly long integer in C/C++, Java, C# then use 0L.
* - JavaScript has only one number type, which is equivalent to a floating point type.
+ 4
It depends on the context. You have not provided any context.
You can print the data type and find out.
+ 4
Oliver Pasaribu this could be either ...
floats are generally precise within 7 decimal points
doubles are generally precise within 15 decimal points
I usually depending on the language go with double.
+ 1
0 is many things like nullptr, NULL, false in C++. maybe it is like that in Java but Java is strict and you should add .f to make it float or widening conversion. If you do not try it, then 0 is default to integer