Integer.valueOf() and Integer.parseInt() supports Fullwidth Number,
but, Double.valueOf() does not support.
And, though java.math.BigDecimal supports Fullwidth Number character,
It can't recognize Fullwidth Point (\uff0e) mark.
Operate the following:
1. Compile & Run attached source code
2. Result on Solaris is as follows,
-----
$ java DoubleTest
123
java.lang.NumberFormatException: £±£².£³£´£µ
java.lang.NumberFormatException: £±£².£³£´£µ
12.345
java.lang.NumberFormatException: £±£²¡¥£³£´£µ
----- DoubleTest.java
import java.math.*;
class DoubleTest {
public static void main(String[] args) throws Exception {
String int_str = "\uff11\uff12\uff13";
String str = "\uff11\uff12.\uff13\uff14\uff15";
String str2 = "\uff11\uff12\uff0e\uff13\uff14\uff15";
try {
int i = Integer.parseInt(int_str);
System.out.println(i);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
try {
Double d = new Double(str);
System.out.println(d);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
try {
Double d2 = Double.valueOf(str);
System.out.println(d2);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
try {
double d4 = new BigDecimal(str).doubleValue();
System.out.println(d4);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
try {
double d5 = new BigDecimal(str2).doubleValue();
System.out.println(d5);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
}
}
-----
koushi.takahashi@japan 1998-07-07
but, Double.valueOf() does not support.
And, though java.math.BigDecimal supports Fullwidth Number character,
It can't recognize Fullwidth Point (\uff0e) mark.
Operate the following:
1. Compile & Run attached source code
2. Result on Solaris is as follows,
-----
$ java DoubleTest
123
java.lang.NumberFormatException: £±£².£³£´£µ
java.lang.NumberFormatException: £±£².£³£´£µ
12.345
java.lang.NumberFormatException: £±£²¡¥£³£´£µ
----- DoubleTest.java
import java.math.*;
class DoubleTest {
public static void main(String[] args) throws Exception {
String int_str = "\uff11\uff12\uff13";
String str = "\uff11\uff12.\uff13\uff14\uff15";
String str2 = "\uff11\uff12\uff0e\uff13\uff14\uff15";
try {
int i = Integer.parseInt(int_str);
System.out.println(i);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
try {
Double d = new Double(str);
System.out.println(d);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
try {
Double d2 = Double.valueOf(str);
System.out.println(d2);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
try {
double d4 = new BigDecimal(str).doubleValue();
System.out.println(d4);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
try {
double d5 = new BigDecimal(str2).doubleValue();
System.out.println(d5);
} catch(NumberFormatException e) {
System.out.println(e.toString());
}
}
}
-----
koushi.takahashi@japan 1998-07-07