floating point problem

Hi!

my english sux, so dont be surprised if you will see grammar mistakes.

in my program i working a lot with strings and then convert them to float.

but, i have a problem when i have a number with 'e' inside string, i can't convert the string to float(with parseFloat()). how i can set to default that the numbers will be represented normally(without 'e')?

any help will be appreciated.

[423 byte] By [zurka] at [2007-10-2 15:14:06]
# 1
Use DecimalFormat to format your values without the 'e'.
MLRona at 2007-7-13 14:14:30 > top of Java-index,Java Essentials,Java Programming...
# 2
Are you asking how to parse strings that are in exponential notation? Or are you asking how to format numbers into strings without using that notation?
jverda at 2007-7-13 14:14:30 > top of Java-index,Java Essentials,Java Programming...
# 3
one of them, it doesn't matter to me
zurka at 2007-7-13 14:14:30 > top of Java-index,Java Essentials,Java Programming...
# 4
java.text.DecimalFormat can help you with both.
jverda at 2007-7-13 14:14:30 > top of Java-index,Java Essentials,Java Programming...
# 5
what method should i use? i didn't find
zurka at 2007-7-13 14:14:30 > top of Java-index,Java Essentials,Java Programming...
# 6

Did you read the docs? There are two main methods. One goes from String to number, the other goes the other way. In both cases you tell it what format the string should take.

Did you play with them to see how they work? What part didn't you understand?

Googling for java decimal format example gave this as the first link:

http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html

and this a little bit further down the page

http://javaalmanac.com/egs/java.text/FormatNum.html

jverda at 2007-7-13 14:14:30 > top of Java-index,Java Essentials,Java Programming...