im curious is there a difference between
const float f = 1.5F;
vs.
const float f = 1.5;
is there a difference??
im curious is there a difference between
const float f = 1.5F;
vs.
const float f = 1.5;
is there a difference??
1.5 is a double, 1.5F is a float
Well, in this case, there is no difference. By default, floating point literals are double precision.
So, 1.5 is double by default.
Check this out:
http://babbage.cs.qc.edu/IEEE-754/Decimal.html
Thus,
1.1 != 1.1f
So,
const double f1 = 1.1F;
const double f2 = 1.1;
Here, f1 != f2 (which can be seen why from the link)
@Ancient Dragon
Oops, didn't see your post.
>is there a difference??
The latter will probably give you a warning about loss of precision, but since the value is representable by both float and double, there's no real problem.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.