how to Round off Floats in Java

Reply

Join Date: May 2008
Posts: 65
Reputation: lich has a little shameless behaviour in the past 
Solved Threads: 4
lich lich is offline Offline
Junior Poster in Training

how to Round off Floats in Java

 
0
  #1
Aug 11th, 2008
can anyone tell me how to round off the values..
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,810
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: how to Round off Floats in Java

 
0
  #2
Aug 11th, 2008
Originally Posted by lich View Post
can anyone tell me how to round off the values..
Check the Math class for problems like this:

http://java.sun.com/j2se/1.4.2/docs/...lang/Math.html
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 65
Reputation: lich has a little shameless behaviour in the past 
Solved Threads: 4
lich lich is offline Offline
Junior Poster in Training

Re: how to Round off Floats in Java

 
0
  #3
Aug 11th, 2008
what i want is this

lets say 2.44534

i want to get it to

2.44

any idea how.. please help me
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 973
Reputation: Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough 
Solved Threads: 107
Alex Edwards's Avatar
Alex Edwards Alex Edwards is offline Offline
Posting Shark

Re: how to Round off Floats in Java

 
0
  #4
Aug 11th, 2008
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,810
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: how to Round off Floats in Java

 
0
  #5
Aug 11th, 2008
Originally Posted by lich View Post
what i want is this

lets say 2.44534

i want to get it to

2.44

any idea how.. please help me
Put that in the original post. We have absolutely no way of knowing that's what you want if you don't tell us, so tell us right away so we don't have to guess. That's also rounding down, not rounding off.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC