/[classpath]/classpath/java/lang/Integer.java
ViewVC logotype

Diff of /classpath/java/lang/Integer.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by ericb, Sat Mar 9 21:20:04 2002 UTC revision 1.28 by tromey, Thu Jun 13 17:28:54 2002 UTC
# Line 138  public final class Integer extends Numbe Line 138  public final class Integer extends Numbe
138    
139          // When the value is MIN_VALUE, it overflows when made positive          // When the value is MIN_VALUE, it overflows when made positive
140          if (num < 0)          if (num < 0)
141            return "" + MIN_VALUE;            {
142                buffer[--i] = digits[(int) (-(num + radix) % radix)];
143                num = -(num / radix);
144              }
145        }        }
146    
147      do      do
# Line 580  public final class Integer extends Numbe Line 583  public final class Integer extends Numbe
583        }        }
584      if (index == len)      if (index == len)
585        throw new NumberFormatException();        throw new NumberFormatException();
586    
587        int max = MAX_VALUE / radix;
588        // We can't directly write `max = (MAX_VALUE + 1) / radix'.
589        // So instead we fake it.
590        if (isNeg && MAX_VALUE % radix == radix - 1)
591          ++max;
592    
593      int val = 0;      int val = 0;
594      while (index < len)      while (index < len)
595        {        {
596            if (val < 0 || val > max)
597              throw new NumberFormatException();
598    
599          ch = Character.digit(str.charAt(index++), radix);          ch = Character.digit(str.charAt(index++), radix);
600          val = val * radix + ch;          val = val * radix + ch;
601          if (ch < 0 || (val < 0 && (index < len || ! isNeg          if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE)))
                                    || val != MIN_VALUE)))  
602            throw new NumberFormatException();            throw new NumberFormatException();
603        }        }
604      return isNeg ? -val : val;      return isNeg ? -val : val;

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26