Changeset 1391 for branches/GNU/src/gcc/libjava/java/math/BigDecimal.java
- Timestamp:
- Apr 27, 2004, 8:39:34 PM (22 years ago)
- Location:
- branches/GNU/src/gcc
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
libjava/java/math/BigDecimal.java (modified) (5 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gcc
- Property svn:ignore
-
old new 26 26 configure.vr 27 27 configure.vrs 28 28 29 Makefile 29 dir.info30 30 lost+found 31 31 update.out
-
- Property svn:ignore
-
branches/GNU/src/gcc/libjava/java/math/BigDecimal.java
-
Property cvs2svn:cvs-rev
changed from
1.1to1.1.1.2
r1390 r1391 179 179 if (point < len) 180 180 { 181 int exp = Integer.parseInt (num.substring (point + 1)); 182 exp -= scale; 183 if (exp > 0) 181 point++; 182 if (num.charAt(point) == '+') 183 point++; 184 185 if (point >= len ) 186 throw new NumberFormatException ("no exponent following e or E"); 187 188 try 184 189 { 185 intVal = intVal.multiply (BigInteger.valueOf (10).pow (exp)); 186 scale = 0; 190 int exp = Integer.parseInt (num.substring (point)); 191 exp -= scale; 192 if (signum () == 0) 193 scale = 0; 194 else if (exp > 0) 195 { 196 intVal = intVal.multiply (BigInteger.valueOf (10).pow (exp)); 197 scale = 0; 198 } 199 else 200 scale = - exp; 187 201 } 188 else 189 scale = - exp; 202 catch (NumberFormatException ex) 203 { 204 throw new NumberFormatException ("malformed exponent"); 205 } 190 206 } 191 207 } … … 199 215 throws NumberFormatException 200 216 { 201 if ( scale == 0)217 if () 202 218 switch ((int) val) 203 219 { … … 253 269 254 270 if (intVal.signum () == 0) // handle special case of 0.0/0.0 255 return ZERO;271 return ; 256 272 257 273 // Ensure that pow gets a non-negative value. … … 416 432 } 417 433 434 435 436 437 438 418 439 public BigDecimal abs () 419 440 { … … 432 453 return bigStr; 433 454 434 int point = bigStr.length() - scale;435 455 boolean negative = (bigStr.charAt(0) == '-'); 436 StringBuffer sb = new StringBuffer(bigStr.length() + 1 + 437 (point <= 0 ? -point+1 : 0)); 438 if (negative) 439 sb.append('-'); 440 while (point <= 0) 441 { 442 sb.append('0'); 443 point++; 444 } 445 sb.append(bigStr.substring(negative ? 1 : 0)); 446 sb.insert(point, '.'); 456 457 int point = bigStr.length() - scale - (negative ? 1 : 0); 458 459 StringBuffer sb = new StringBuffer(bigStr.length() + 2 + 460 (point <= 0 ? (-point + 1) : 0)); 461 if (point <= 0) 462 { 463 if (negative) 464 sb.append('-'); 465 sb.append('0').append('.'); 466 while (point < 0) 467 { 468 sb.append('0'); 469 point++; 470 } 471 sb.append(bigStr.substring(negative ? 1 : 0)); 472 } 473 else 474 { 475 sb.append(bigStr); 476 sb.insert(point + (negative ? 1 : 0), '.'); 477 } 447 478 return sb.toString(); 448 479 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
