Closed markusachtelik closed 11 years ago
Why not allowing the decimal point without the trailing decimal, like float x = 0.f;
?
ok foe me, all I wanted to point out is the f
indicating a float
I agree, although for templates that can be float or double it is better left out, maybe in these cases we should request explicit cast, like:
template<typename FloatingType>
struct A
{
FloatingType getZero() const { return FloatingType(0.); }
};
Wow, I can't believe that in Markus' example the conversion isn't done at compile time. Can someone explain that to me? (0.0 is obviously a constexpr and the conversion double to float should be one as well. So why is it done at runtime?) Maybe that was a buggy / old compiler?
for 32 bit floating point values, writing
float x = 0.0
can lead to performance issues especially for embedded platforms, since apparently a double is assumed (someone told me it happened on a cortex), sofloat x = 0.0f
should be preferred.