Thanks and Regards, Amit Taneja
depends on what ??
how long to float is allowed ...i mean on what basis...
An implicit cast from long to float is allowed because the float has a larger range. The MAX_VALUE and MIN_VALUE for a float is larger and smaller than the MAX_VALUE and MIN_VALUE for a long respectively. Of course, you do lose information, since you are going from 64 bits to 32 bits. What you lose is precision. Even though a positive float number can get bigger than a long, it doesn't have as many significant bits.
Thanks and Regards, Amit Taneja
Thanks and Regards, Amit Taneja
Originally posted by Steven Bell:
To understand why requires some understanding of floating point representation, but from a logic though process if a float is 32 bits while a long is 64 bits the float, having a 'wider' range than the long, must be unable to represent some of the numbers within it's range.
[ June 02, 2005: Message edited by: Steven Bell ]
Thanks and Regards, Amit Taneja
Originally posted by amit taneja:
------------------------------------
so the final conclusion is while casting from integer type to floating type
if no. is large some information is going to lost...
and even then it is implicitly castable...
and we ourself must be carefull while puting long to float...
---------------------------------
pls give comment on final conclusion... and other then that it seems bit illogical that compiler give error of warning when narrowing that presion will be lost..
but it not giving error while widening...its just a comment...don't take otherwise..
regards
but do comment on final conclusion and this post
Thanks and Regards, Amit Taneja
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |