I should also mention that I tried this as well... public static void main(String[] args) { DecimalFormat dollarFormat = new DecimalFormat("$#0.00"); System.out.println(dollarFormat.format(71.815)); System.out.println(dollarFormat.format(71.825)); System.out.println(dollarFormat.format(71.835)); System.out.println(dollarFormat.format(71.845)); System.out.println(dollarFormat.format(71.855)); System.out.println(dollarFormat.format(71.865)); System.out.println(dollarFormat.format(71.875)); System.out.println(dollarFormat.format(71.885)); System.out.println(dollarFormat.format(71.895)); }
It gives the same exact results. Everything is fine as long as it's not a 5 in the 1000ths position. -----Original Message----- From: Bobby Hartsfield [mailto:[EMAIL PROTECTED] Sent: Friday, October 06, 2006 9:19 PM To: CF-Talk Subject: OT: Java help 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 doesnt 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:255868 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4