Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2007

Tip: Looking for answers? Try searching our database.

DecimalFormat.format() misbehaved on my machine

Thread view: 
ps - 27 Aug 2007 06:13 GMT
Hi,

I found this description in the API doc:

The number of significant digits in the mantissa is the sum of the
minimum integer and maximum fraction digits, and is unaffected by the
maximum integer digits. For example, 12345 formatted with "##0.##E0"
is "12.3E3".

But when I tried it out, I got different results:
System.out.println(new DecimalFormat("##0.##E0").format(12345));    //
prints 12.345E3

I then took one '#' away from both ends in turn, but still got
unexpected results:
System.out.println(new DecimalFormat("#0.##E0").format(12345));   //
prints 1.234E4
System.out.println(new DecimalFormat("##0.#E0").format(12345));   //
prints 12.34E3

My platform's Win Xp Pro x64 Sp2, and I'm using Java 1.6.

Has anyone else observed the same behavior on different platforms?

Regards,
PS
a24900@googlemail.com - 27 Aug 2007 07:07 GMT
> But when I tried it out, I got different results:
> System.out.println(new DecimalFormat("##0.##E0").format(12345));    //
> prints 12.345E3

It's a four year old bug. And when reported it was already a few years
old:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4871921


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.