Linked Questions
67 questions linked to/from How to nicely format floating numbers to string without unnecessary decimal 0's
0 votes
2 answers
277 views
Format Doubles to String [duplicate]
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/...
0 votes
1 answer
411 views
Java String format float with and without 0 [duplicate]
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....
-1 votes
1 answer
512 views
Java Swing g.drawstring "int or double "without getting scientific notation Aka E [duplicate]
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 ...
1 vote
1 answer
552 views
Java format double to string with minimal precision [duplicate]
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 ...
-1 votes
2 answers
445 views
How do i remove .0 from the result if the resultant number is a full number in a calculator [duplicate]
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 ...
1 vote
1 answer
274 views
Remove useless zero after the point [duplicate]
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 < ...
-1 votes
2 answers
101 views
ITRemoving zero from decimal part of float [duplicate]
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 ...
-3 votes
6 answers
286 views
Convert a specific double to string [duplicate]
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....
2 votes
0 answers
58 views
Format double as integer when no decimal places [duplicate]
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 : ...
2 votes
0 answers
44 views
Can you use printf() in Java for a float and not have trailing zeroes, but still have all necessary decimals? [duplicate]
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 ...
0 votes
0 answers
43 views
How to get rid of .0 on end of whole float number [duplicate]
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 ...
25 votes
3 answers
56k views
How to remove the " .0" in a whole number when using double in java? [duplicate]
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 ...
14 votes
9 answers
28k views
How to remove the decimal part from a float number that contains .0 in java
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, ...
24 votes
3 answers
44k views
Scientific Notation precision normalizing
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. >&...
6 votes
8 answers
23k views
in Java, how to delete all 0s in float?
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 ...