Thanitsak Leuangsupornpong7,490 Points
Why 0.0 is not float? Why the complier chooses it to be double?
I am just curious, because as I know there is also the keyword "float" that can store decimal point. Thank you in advance
Steven Parker174,085 Points
Microsoft chose the default type to be double when creating the language.
Here's a clip from an old Microsoft language specification:
If no real type suffix is specified, the type of the real literal is double. Otherwise, the real type suffix determines the type of the real literal, as follows:
- A real literal suffixed by F or f is of type float. For example, the literals 1f, 1.5f, 1e10f, and 123.456F are all of type float.
- A real literal suffixed by D or d is of type double. For example, the literals 1d, 1.5d, 1e10d, and 123.456D are all of type double.
- A real literal suffixed by M or m is of type decimal. For example, the literals 1m, 1.5m, 1e10m, and 123.456M are all of type decimal.