1

I am going to develop a calculator on android platform, it is fine in calculating numbers less than 1000000, when I tried to add 1000000 with 0, the result is "1.0000E7"?! I try to change the type of result from float to double, but the problem is still here, I try to use long, result becomes normal, but it cannot calculate decimal place anymore....

1
  • Please show as the code that is responsible for printing the result. Commented Jul 6, 2010 at 7:04

3 Answers 3

3

For your output use String.format(String format, Object... args)

and see Formatter for an overview on how to use the different placeholders/format specifiers (you will be especially interested in Floating-point conversions, ctrl-f it).

Sign up to request clarification or add additional context in comments.

Comments

1

The calculation and the result are completely fine. 1.0000E7 is the correct result. See Scientific Notation for more information. If you don't want the number to be shown this way you have to change the way you create the output string out of your result.

Comments

0

The output just switched over to scientific notation. The solution is hidden in that part of your code that prints the result on the screen (widget).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.