File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help in Float comparison" Watch "Help in Float comparison" New topic

Help in Float comparison

Anusha Jv

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.
Michael Fitzmaurice
Ranch Hand

Joined: Aug 22, 2001
Posts: 168
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

Joined: Jul 26, 2001
Posts: 19
Thanks It works fine.
I agree. Here's the link:
subject: Help in Float comparison
It's not a secret anymore!