wood burning stoves 2.0*
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 Java 8 in Action this week in the Java 8 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: 10929
    
  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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to convert string to number?
 
Similar Threads
just basic division
variables
converting float hex to int
casting String to ?
Number Conversion Problem