Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help in Float comparison

 
Anusha Jv
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anusha Jv
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks It works fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic