Manning's Countdown to 2014
. Use discount code crdotd14 all month for 50% off every deal.
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,<br />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
It is sorta covered in the
JavaRanch Style Guide
subject: why float == long
primitive widening doubt
how does long fit in float ?
Long to Float conversion
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013