aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How is huge Integer value converted to float Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How is huge Integer value converted to float" Watch "How is huge Integer value converted to float" New topic
Author

How is huge Integer value converted to float

Tina Tibrewal
Ranch Hand

Joined: Apr 19, 2007
Posts: 40


The output is -3 false.
Can anyone explain this.

And one more


f and d are not equal. Why?
raj malhotra
Ranch Hand

Joined: Feb 22, 2007
Posts: 285
Hi Tina
both int and float uses 32 bits but...
int uses 32 bits to store the int value
whereas float uses 32 bits to store significant number plus fraction part also. so number of bits are less than 32 to store a significant value .so float will store approx. close value for large int not exact. that is why you are getting 3 and false.


same reason for second question

[ April 20, 2007: Message edited by: raj malhotra ]
[ April 20, 2007: Message edited by: raj malhotra ]
Tina Tibrewal
Ranch Hand

Joined: Apr 19, 2007
Posts: 40
yep got it!!

Thanks.
 
Consider Paul's rocket mass heater.
 
subject: How is huge Integer value converted to float