File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
why float == long
Joined: Mar 14, 2003
Jan 19, 2005 08:19:00
can any body please tell me why in code
then answer is true !!!
I know variables contains bits representing the value and here above 5.0 ( i think its double ) is equal to 5 ( long ) why ?
is it because both are 64 bits..
but what about long store decimals in bits.. how it can be same ?
thanx and regards
Thanks and Regards, Amit Taneja
Joined: Jan 08, 2005
Jan 19, 2005 10:59:00
During == operator i think long gets promoted to float as 5.0 and hence the == operator returns true. The same can be observed during comparisons of the following types:=
int == long
short == byte
I agree. Here's the link:
subject: why float == long
Long to Float conversion
how does long fit in float ?
primitive widening doubt
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015