178 |
// Now parse exponent. |
// Now parse exponent. |
179 |
if (point < len) |
if (point < len) |
180 |
{ |
{ |
181 |
int exp = Integer.parseInt (num.substring (point + 1)); |
point++; |
182 |
exp -= scale; |
if (num.charAt(point) == '+') |
183 |
if (exp > 0) |
point++; |
184 |
|
|
185 |
|
if (point >= len ) |
186 |
|
throw new NumberFormatException ("no exponent following e or E"); |
187 |
|
|
188 |
|
try |
189 |
{ |
{ |
190 |
intVal = intVal.multiply (BigInteger.valueOf (10).pow (exp)); |
int exp = Integer.parseInt (num.substring (point)); |
191 |
scale = 0; |
exp -= scale; |
192 |
|
if (exp > 0) |
193 |
|
{ |
194 |
|
intVal = intVal.multiply (BigInteger.valueOf (10).pow (exp)); |
195 |
|
scale = 0; |
196 |
|
} |
197 |
|
else |
198 |
|
scale = - exp; |
199 |
|
} |
200 |
|
catch (NumberFormatException ex) |
201 |
|
{ |
202 |
|
throw new NumberFormatException ("malformed exponent"); |
203 |
} |
} |
|
else |
|
|
scale = - exp; |
|
204 |
} |
} |
205 |
} |
} |
206 |
|
|
445 |
if (scale == 0) |
if (scale == 0) |
446 |
return bigStr; |
return bigStr; |
447 |
|
|
|
int point = bigStr.length() - scale; |
|
448 |
boolean negative = (bigStr.charAt(0) == '-'); |
boolean negative = (bigStr.charAt(0) == '-'); |
449 |
StringBuffer sb = new StringBuffer(bigStr.length() + 1 + |
|
450 |
(point <= 0 ? -point+1 : 0)); |
int point = bigStr.length() - scale - (negative ? 1 : 0); |
451 |
if (negative) |
|
452 |
sb.append('-'); |
StringBuffer sb = new StringBuffer(bigStr.length() + 2 + |
453 |
while (point <= 0) |
(point <= 0 ? (-point + 1) : 0)); |
454 |
|
if (point <= 0) |
455 |
|
{ |
456 |
|
if (negative) |
457 |
|
sb.append('-'); |
458 |
|
sb.append('0').append('.'); |
459 |
|
while (point < 0) |
460 |
|
{ |
461 |
|
sb.append('0'); |
462 |
|
point++; |
463 |
|
} |
464 |
|
sb.append(bigStr.substring(negative ? 1 : 0)); |
465 |
|
} |
466 |
|
else |
467 |
{ |
{ |
468 |
sb.append('0'); |
sb.append(bigStr); |
469 |
point++; |
sb.insert(point + (negative ? 1 : 0), '.'); |
470 |
} |
} |
|
sb.append(bigStr.substring(negative ? 1 : 0)); |
|
|
sb.insert(point, '.'); |
|
471 |
return sb.toString(); |
return sb.toString(); |
472 |
} |
} |
473 |
|
|