Linked Questions

82 votes
3 answers
177k views

For example I need 5.0 to become 5, or 4.3000 to become 4.3.
Wrath's user avatar
  • 885
11 votes
1 answer
8k views

I need to to show decimal places of a float value only when it is different from zeros. 5.0 should be shown as 5. 7.3 should be shown as 7.3. 9.000003 should be shown as 9.000003. How to format in ...
Rodrigo Rocha's user avatar
14 votes
3 answers
30k views

How do I remove trailing zeros in a String value and remove decimal point if the string contains only zeros after the decimal point? I'm using the below code: String string1 = Double.valueOf(a)....
Marjer's user avatar
  • 1,413
9 votes
3 answers
11k views

I know how to format a double to keep only the available decimal places (DP), up to a certain number of DPs. This example keeps up to 4 DPs. double d = 1.0; DecimalFormat df = new ...
Jean-François Corbett's user avatar
4 votes
2 answers
10k views

Possible Duplicate: How to nicely format floating types to String? I have number: Double d1=(Double)0; Double d2=(Double)2.2; Double d3=(Double)4; When I use to String, I get 0.0, 2.2, 4.0, but ...
Ivan's user avatar
  • 191
2 votes
2 answers
1k views

Is there a way to set String.format so that it won't display 00 decimals? For example I would like: String.format("%.2f", 12.345d) to display 12.34 but String.format("%.2f", 12.3d) to display 12.3 ...
lucian.marcuta's user avatar
0 votes
1 answer
4k views

I got trouble with format number in JasperReports. For example, i have a double value, and i put the format pattern like #,##0.000 Now, with value of number 1.123, i got what i want, but if the value ...
CNNPX's user avatar
  • 1
0 votes
3 answers
2k views

I've got a series of float numbers; I want to display them as they are; but while I use String.getValueOf .0 will be added to my numbers ie 10 is shows as 10.0 what should i do to prevent this mess ?
Shervin4030's user avatar
2 votes
3 answers
495 views

I have double values in Java like the following: 2.3422 45.3267 25.0 What I want to print is: 2.34 45.32 25 So I used the following method DecimalFormat form=new DecimalFormat("#0.00"); form.format(...
J J's user avatar
  • 165
0 votes
3 answers
770 views

I want to limit my numbers to 7 significant figures (I believe this is known as significant digits in American English) with a maximum of 5 decimal places but I am ensure on how to do this. I am ...
Lerp's user avatar
  • 3,177
0 votes
2 answers
2k views

My program is supposed to calculate change: double purchaseAmount = Double.parseDouble(s1); double amountGiven = Double.parseDouble(s2); double change = purchaseAmount - amountGiven; JOptionPane....
Nikron69's user avatar
0 votes
2 answers
2k views

I have looking for the solution around and doing a little workaround here, but can not wrap up all to meet my expectations. For example, I have double values as below double x = 101.00000 double y = ...
Fran Na Jaya's user avatar
0 votes
2 answers
1k views

How can I make a float value to only show the dot and the decimals if they exist. For example show 17 instead of 17.0 but if I have a 17.2 show the dot and the decimals. Thanks!
Genis's user avatar
  • 37
2 votes
3 answers
375 views

I'm finding a logarithm of value 1 which is equal to 0 not 0.0. When user enter any point values then it give exact answer. But the problem is Which Value Does Not Consist in points it give the answer ...
user avatar
-2 votes
3 answers
564 views

I would like to know how can I show in my TextView the price as follows: Price is a double value. a=8.75 and b=9.00 I need display a=8.75 and b=9. I supose I need to check something and change its ...
Héctor Prats's user avatar

15 30 50 per page
1
2 3 4 5