[Solved] Decltype(0.5) x = 5; makes x *Double* rather than *Float*. Why? [duplicate]
The type of 0.5 in C++ is double. If you want a float you need to say 0.5f . This is part of the definition of C and C++. Implied in your question is some desire for automatic type selection based on the number of digits in the value, e.g. we could use float for … Read more