HighTechTalks DotNet Forums  

DecimalFormat ignoring exponent?

Dotnet VJSharp microsoft.public.dotnet.vjsharp


Discuss DecimalFormat ignoring exponent? in the Dotnet VJSharp forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Xiao Ma
 
Posts: n/a

Default DecimalFormat ignoring exponent? - 02-27-2006 , 03:12 PM






I use java.text.DecimalFormat returned from NumberFormat.getInstance to
parse numbers like 9E03 and 9.1E03. But it seems to ignore the exponent
and returns me 9 and 9.1, respectively. This is inconsistant with Java.
Is this a known problem? Is there a workaround?

Thanks in advance.

Xiao Ma


Reply With Quote
  #2  
Old   
Xiao Ma
 
Posts: n/a

Default Re: DecimalFormat ignoring exponent? - 03-01-2006 , 01:46 PM






Here is the sample program:

==========Foo.java===============
import java.text.*;

/**
*/
public class Foo
{
/** @attribute System.STAThread() */
public static void main(String[] args) throws Exception
{
NumberFormat format = NumberFormat.getNumberInstance();
System.out.println(format.parse("9E3"));
System.out.println(format.parse("9.1E3"));
}
}
=================================

The output in J# is 9 and 9.1. In Java, it's 9000 and 9100.

Xiao


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.