• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How is huge Integer value converted to float

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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

And one more


f and d are not equal. Why?
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yep got it!!

Thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic