Can anyone lend a hand with this off-list by chance? I need a dollarformat
function in Java. I thought I had it but it doesn’t round correctly. Take
this short example.

 

import java.text.*;

import java.util.Locale;

 

public class dollarFormattingTest

{

            public static void main(String[] args)

            {

                        NumberFormat dollarFormat =
NumberFormat.getCurrencyInstance(Locale.US);

                        System.out.println(dollarFormat.format(71.715));

                        System.out.println(dollarFormat.format(71.725));

                        System.out.println(dollarFormat.format(71.735));

                        System.out.println(dollarFormat.format(71.745));

                        System.out.println(dollarFormat.format(71.755));

                        System.out.println(dollarFormat.format(71.765));

                        System.out.println(dollarFormat.format(71.775));

                        System.out.println(dollarFormat.format(71.785));

                        System.out.println(dollarFormat.format(71.795));

            }

}

 

That short program outputs the following

 

$71.72

$71.72

$71.74

$71.74

$71.76

$71.76

$71.78

$71.78

$71.80

 

If I change all the numbers to put a 6 in the 1000ths position, compile, and
run again they all round up fine just as they should. And anything under a 5
in that position seems fine as well (the 1000ths position is simply
dropped).

 

Any ideas? 


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.407 / Virus Database: 268.13.0/465 - Release Date: 10/6/2006
 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255867
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to