decimalformat Questions

2

Solved

I`ve got (and will receive in the future) many CSV files that use the semicolon as delimiter and the comma as decimal separator. So far I could not find out how to import these files into SAS using...
Sandblind asked 5/2, 2015 at 15:6

2

Solved

Why does java.text.DecimalFormat evaluate the following results: new DecimalFormat("0.#").format(23.0) // result: "23" new DecimalFormat(".#").format(23.0) // result: "23.0" I would have expect...
Pirate asked 22/3, 2016 at 15:17

4

Solved

I would like to remove all trailing zeros without truncating or rounding the number if it doesn't have any. For example, the number could be something like 12.0, in which case, the trailing zero sh...
Mona asked 1/7, 2012 at 19:17

5

Solved

I am trying to keep two decimal places, even if then numbers are zeroes, using DecimalFormatter: DecimalFormat df = new DecimalFormat("#.00"); m_interest = Double.valueOf(df.format(m_principal * ...
Mccloud asked 9/12, 2013 at 4:31

1

Solved

I have a product I built in the US. A friend in Poland was testing it today and the localized number formatting created some exceptions. I would like to simulate running my program in Poland or Ge...
Kyat asked 16/10, 2015 at 3:16

4

Solved

I've used DecimalFormat df = new DecimalFormat("#,###.00"); to format a BigDecimal. Now, I want to use that formatted value (say it is '1 250,00') to create new BigDecimal. I've tried this: BigDe...
Listerism asked 3/9, 2015 at 11:32

2

Solved

NB: To the best of my knowledge this question is not a duplicate! All the questios/answers I found are either how to eliminate points from data that are already in R or how to change the decimal po...
Tiberius asked 13/5, 2015 at 14:42

2

Solved

I am using the following code to make numbers display with two decimal places and thousands comma separator. public static String formatNumber(double amount){ DecimalFormat formatter = new Decima...
Limicolous asked 3/11, 2014 at 2:6

2

This relates to my previous question, which can be found at: Math equation result loses decimals when displayed In my assignment, we have to calculate the perimeter of an isosceles trapezoid. The...
Harshman asked 30/9, 2014 at 19:24

2

Solved

I am developing an Android app where I want to format my double number to #.##, which I have done using below code. Double BMI = ((fWeight)/(dHeight*dHeight)); DecimalFormat df = new DecimalFormat...
Dolley asked 15/5, 2013 at 4:52

4

Solved

So I want to use the Decimal Format class to round numbers: double value = 10.555; DecimalFormat fmt = new DecimalFormat ("0.##"); System.out.println(fmt.format(value)); Here, the variable val...
Gannet asked 10/2, 2014 at 1:58

6

I am having problems using DecimalFormat when I am going to print out coefficients after a regression. Here is the part of the code that is facing problems; DecimalFormat twoDForm = new DecimalF...
Bechtold asked 17/9, 2010 at 13:18

4

Solved

I have this String: 10,692,467,440,017.120 (it's an amount). I want to parse it to a BigDecimal. The problem is that I have tried both DecimalFormat and NumbeFormat in vain.
Lindberg asked 14/8, 2013 at 12:30

2

Solved

I'm trying to format some numbers in a Java program. The numbers will be both doubles and integers. When handling doubles, I want to keep only two decimal points but when handling integers I want t...
Cochise asked 30/4, 2013 at 21:23

10

Solved

Possible Duplicate: Moving decimal places over in a double Why is the following sum of numbers not equal to 0.4622? but 0.46219999999999994 Double total = new Double(0.08) + new Doub...
Verdugo asked 8/1, 2013 at 14:53

1

Can someone explain to me why the below code gives this output? 1.2 null Running the following code: String positive = "1.2+"; String negative = "1.2-"; DecimalFormat format = new DecimalFormat...
Stepsister asked 2/7, 2012 at 18:40

2

Solved

Let's look at the following statements in Java. System.out.println(new DecimalFormat("0").format(2.4)); //returns 2 System.out.println(new DecimalFormat("0").format(2.5)); //returns 2 <---Conc...
Unilateral asked 13/4, 2012 at 16:23

3

Solved

public static String formatAmountUpToTwoDecimalNumber(String amount) { if(amount==null || "".equals(amount)) { return ""; } Double doubleAmount = Double.valueOf(amount); double myAmount = ...
Leisurely asked 14/12, 2011 at 10:31

2

I am quite confused about this peculiar 'error' I am getting when parsing a String to a Double. I've already set up the NumberFormat properties and symbols. When passing a String with 15 digits a...
Melanson asked 16/8, 2011 at 9:33

1

Solved

I have a double and i am trying to convert it to a decimal. When i use decimalformat to achieve this i get the following: public void roundNumber(){ double d = 2.081641999208976E-4; JOptionPane....
Spectrophotometer asked 29/7, 2011 at 20:25

3

The central problem is that I have a series of doubles that I need to log, each with varying number of significant digits. The numbers vary greatly in how many significant digits they have. Some ha...
Azerbaijani asked 29/7, 2011 at 5:48

3

Solved

Using DecimalFormat gives no parse exception when using this kind of number: 123hello which is obviously not really a number, and converts to 123.0 value. How can I avoid this kind of behaviour? ...
Florafloral asked 6/7, 2011 at 17:28

2

Solved

I am using DecimalFormat to create a formated decimal that is always 6 characters long. At first I used the format string of new DecimalFormat("000.00") but this gave me a bug for negative numbers....
Posen asked 17/2, 2011 at 16:3

4

Solved

I want to be able to convert a string to a Double given a number of decimal places in a format string. So "###,##0.000" should give me a Double to 3 decimal places. Edit - added more info to what ...
Lachrymal asked 19/1, 2011 at 17:59

2

Solved

I am using the following DecimalFormat pattern: // Use ThreadLocal to ensure thread safety. private static final ThreadLocal <NumberFormat> numberFormat = new ThreadLocal <NumberFormat&g...
Consecrate asked 13/12, 2010 at 13:16

© 2022 - 2024 — McMap. All rights reserved.