all groups > vj# > february 2006 >
You're in the

vj#

group:

DecimalFormat ignoring exponent?


DecimalFormat ignoring exponent? Xiao Ma
2/27/2006 12:12:27 PM
vj#: 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
Re: DecimalFormat ignoring exponent? Lars-Inge Tønnessen (VJ# MVP)
2/28/2006 7:10:17 PM

Please make a small sample application to dempnstrate the problem.

Best Regards,
Lars-Inge Tønnessen

Re: DecimalFormat ignoring exponent? Xiao Ma
3/1/2006 10:46:36 AM
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
Re: DecimalFormat ignoring exponent? Lars-Inge Tønnessen (VJ# MVP)
3/19/2006 6:30:00 PM
Looks like a bug to me.

It should be the same as Java.

Regards,
Lars-Inge Tønnessen

AddThis Social Bookmark Button