This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Help in Float comparison Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help in Float comparison" Watch "Help in Float comparison" New topic
Author

Help in Float comparison

Anusha Jv
Greenhorn

Joined: Jul 26, 2001
Posts: 19
Hi all,
I have two String(TextField value) which take floating point value.
I want to compare them by rounding.
Please tell the way to do it.
Thanks
Michael Fitzmaurice
Ranch Hand

Joined: Aug 22, 2001
Posts: 168
Hi
First you need to convert the Strings to floats - use <code>Float.parseFloat()</code>. Then you need to round the 2 resulting floats to ints - use <code>Math.round()</code> on them both. Then do simple int comparison to find out what you need to know.
Hope this helps

"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
Anusha Jv
Greenhorn

Joined: Jul 26, 2001
Posts: 19
Thanks It works fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help in Float comparison
 
Similar Threads
how to reset the field after validation using annotations(Struts 2)
Doubt in EL Implicit Objects: Cookie
jsp bean problem
How to convert the for Loop to the equalent JSTL code in JSP
Tricky Question