aspose file tools*
The moose likes Beginning Java and the fly likes How to convert string to number? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to convert string to number?" Watch "How to convert string to number?" New topic
Author

How to convert string to number?

Mr Tan Ah Seng
Greenhorn

Joined: Sep 20, 2004
Posts: 2
Hi,

I need help.

I use Integer.parseInt to convert string in integer format(example 123) to integer number without problem.

However, I have problem using Integer.parseInt to convert a string in float number format(example 1.23) to float number, so that I can use it for calculation.

Thanks.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10905
    
  12

you can't use Integer.parseInt to get a float - it returns an int!!!

but i bet you COULD use Float.parseFloat...


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Mr Tan Ah Seng
Greenhorn

Joined: Sep 20, 2004
Posts: 2
Yes, I can do it now.
Thanks for your help.
 
Don't get me started about those stupid light bulbs.
 
subject: How to convert string to number?
 
Similar Threads
variables
just basic division
Number Conversion Problem
casting String to ?
converting float hex to int