Linked Questions

0 votes
2 answers
277 views

Possible Duplicate: How to nicely format floating types to String? How can I list the number with up to two decimal places? I tried this method: http://developer.android.com/reference/java/text/...
Karol's user avatar
  • 185
0 votes
1 answer
411 views

I have a float number, let's say: Float number = 2.667f; String.format("%.1f", number) will produce: 2,7 but in case of Float number = 2.0f; it will produce: 2,0 is it possible to instruct String....
alexanoid's user avatar
  • 26.1k
-1 votes
1 answer
512 views

So the title says it all, Ive got a problem when trying to type out a larg number using the g.drawstring but im just getting an E in my number. What can i do to prevent this? Thanks / Code static ...
Kappa Coder's user avatar
1 vote
1 answer
552 views

How to get double value printed in formatted string with minimal precision? Example: double v = 2.02; String.format("%f", v); Default %f format always prints 6 digits after point => "2.020000". What ...
smile-on's user avatar
  • 2,203
-1 votes
2 answers
445 views

I am making an android calculator in android studio. But, in my calculator when the result is a full number, the number appears with decimal 0. For example, if i add 9 and 11 the result is appearing ...
Chatur's user avatar
  • 5
1 vote
1 answer
274 views

To remove useless zeros after the point, I use the following method if (("" + unitValue).endsWith(".0")) { return String.format("%.0f %s", unitValue, unitFaName); } else if (unitValue < ...
Delay's user avatar
  • 85
-1 votes
2 answers
101 views

I have floats like these, 0.0 , 50.0 ... How do I convert them to: 0 , 50 ... I need the meaningful numbers in the decimal part stay intact; so 13.59 must remain 13.59. EDIT : my question is way ...
Shervin4030's user avatar
-3 votes
6 answers
286 views

If I have a double storing 10.0 what is the best way to convert it to string 10? Currently I do: if (object.getValue() > 9.999) { someObject.setText(String.format("%d", new Double(object....
Jim's user avatar
  • 19.7k
2 votes
0 answers
58 views

I am trying to write a java function that will take a double as it's input, and return the double formatted as a string to the minimum number of decimal places required. E.g. Input:Result 50.000 : ...
Jonathan Windridge's user avatar
2 votes
0 answers
44 views

So if I have the float variable interval and I want to print it, I want it to print with all of the necessary figures and no extra. If I use System.out.printf("%f", interval); where float ...
Justin Iaconis's user avatar
0 votes
0 answers
43 views

I am trying to get rid of the .0 left behind a float number when I add whole numbers together. ex. if i do 10+10 it will print out 20.0 but i want it to print out 20 unless there is a decimal in the ...
Daniel's user avatar
  • 15
25 votes
3 answers
56k views

Possible Duplicate: How do I format a number in java? I have problems in using Double. When the result is a whole number, it would display with a " .0" like 1.0, 2.0. Can anyone help me how to ...
ikzton's user avatar
  • 273
14 votes
9 answers
28k views

I just want to remove the fractional part of a float number that contains .0. All other numbers are acceptable.. For example : I/P: 1.0, 2.2, 88.0, 3.56666, 4.1, 45.00 , 99.560 O/P: 1 , 2.2, ...
vnshetty's user avatar
  • 20.2k
24 votes
3 answers
44k views

My goal is simply to convert a string such as "1.2" to scientific notation without adding additional precision. The problem is that I always end up with superfluous 0s at the end of my output. >&...
Alex Pritchard's user avatar
6 votes
8 answers
23k views

I'd like to change float like this way: 10.5000 -> 10.5 10.0000 -> 10 How can I delete all zeros after the decimal point, and change it either float (if there's non-zeros) or int (if there were only ...
clerksx's user avatar
  • 640

15 30 50 per page