decimalformat

What is up with this in ColdFusion's DecimalFormat() function? How do I get the correct result?

<cfset number1 = 20.5/80 * 100 /> <cfset number2 = 18.125 /> <cfset number3 = 6.875 /> <cfoutput> DecimalFormat(#number1#): #DecimalFormat(number1)#<br /> DecimalFormat(#number2#): #DecimalFormat(number2)#<br /> DecimalFormat(#number3#): #DecimalFormat(number3)# </cfoutput> OUTPUTS: DecimalFormat(25.625): 25.62 DecimalFormat(18.125)...

What is the c# equivalent of Java DecimalFormat?

How would I convert the following code to C# DecimalFormat form String pattern = ""; for (int i = 0; i < nPlaces - nDec - 2; i++) { pattern += "#"; } pattern += "0."; for (int i = nPlaces - nDec; i < nPlaces; i++) { pattern += "0"; } form = (DecimalFormat) NumberFormat.getInstance(); DecimalFormatSymbols symbols = form....

Using DecimalFormat--keeping extra zeros

I'm using DecimalFormat to format doubles to 2 decimal places like this: DecimalFormat dec = new DecimalFormat("#.##"); double rawPercent = ( (double)(count.getCount().intValue()) / (double)(total.intValue()) ) * 100.00; double percentage = Double.valueOf(dec.format(rawPercent)); It works, but if i have a ...

can't use DecimalFormat class within Eclipse

i am developing a blackberry project through the latest eclipse IDE. i am wanting to use the DecimalFormat class, however, i have noticed that eclipse doesn't recognize this class. Even if i change the JDK compliance level to 1.5, the project rebuilds fine but it still won't recognize it (so you still see the class underlines with red li...

DecimalFormat for price formatting in java

Is it possible to format price according to rules like this using DecimalFormat in Java: 50000 => 50 000 rub 00 kop ...

DecimalFormat and Double.valueOf()

Hello. I'm trying to get rid of unnecessary symbols after decimal seperator of my double value. I'm doing it this way: DecimalFormat format = new DecimalFormat("#.#####"); value = Double.valueOf(format.format(41251.50000000012343)); But when I run this code, it throws: java.lang.NumberFormatException: For input string: "41251,5" ...

Java DecimalFormat creates error when enforcing exponent sign

In Java, I am trying to get DecimalFormat to enforce the sign on an exponent sign. When it is positive I need a plus sign to appear. From what I have read this seems like a no brainer, but for myself it always throws up an error. I appreciate that there may be other methods to achieve my goal, but I would like to understand why in this s...

How to always show decimal part when using DecimalFormat ?

Float sum = new Float(300); // always somehow calculated DecimalFormat df = new DecimalFormat("#.#"); String s = df.format(sum/3); // prints 100, I want 100.0 s = df.format(301/3); // pritns 100.3 which is correct Result should always be formatted to 1 decimal palce, how to do so? ...

How to format a TextEdit while changeText?

Hello together, i try to build an TextEdit (AutocompleteTextView) that format his text with an DecimalFormatter! The TextEdit is set to numeric integer, so only can type numbers. Now i want to format it while writing (or after) to format it like normal money format like: public String formatAmount(String currentValue, String loc){ ...

Problems using DecimalFormat

Hi! 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 DecimalFormat("0.00"); private double s(double d){ return Double.valueOf(twoDForm.format(d)); } and here is the error message in...