• Post Reply Bookmark Topic Watch Topic
  • New Topic

Double to float  RSS feed

 
kiran nyala
Ranch Hand
Posts: 55
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to convert Double value to float without round value... can we do this?
in below code i am getting rounded float value but i don't want to round the Double value while storing in to float variable



 
Rob Spoor
Sheriff
Posts: 21131
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need a float, why call intValue()?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to rethink what you need to do. Doubles and floats are NEVEr 100% precise. It's just the nature of how numbers are stored in computers (this has nothing to do with java).

Also, you realize that calling intValue "returns the value of the specified number as an int" - which means it is going to round it off to an integer?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!