/[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.32 by mark, Sat Jul 2 20:32:38 2005 UTC revision 1.33 by glavaux, Sun Sep 4 09:47:13 2005 UTC
# Line 718  public final class Integer extends Numbe Line 718  public final class Integer extends Numbe
718      int len = str.length();      int len = str.length();
719      boolean isNeg = false;      boolean isNeg = false;
720      if (len == 0)      if (len == 0)
721        throw new NumberFormatException();        throw new NumberFormatException("string length is null");
722      int ch = str.charAt(index);      int ch = str.charAt(index);
723      if (ch == '-')      if (ch == '-')
724        {        {
725          if (len == 1)          if (len == 1)
726            throw new NumberFormatException();            throw new NumberFormatException("pure '-'");
727          isNeg = true;          isNeg = true;
728          ch = str.charAt(++index);          ch = str.charAt(++index);
729        }        }
# Line 748  public final class Integer extends Numbe Line 748  public final class Integer extends Numbe
748            }            }
749        }        }
750      if (index == len)      if (index == len)
751        throw new NumberFormatException();        throw new NumberFormatException("non terminated number: " + str);
752    
753      int max = MAX_VALUE / radix;      int max = MAX_VALUE / radix;
754      // We can't directly write `max = (MAX_VALUE + 1) / radix'.      // We can't directly write `max = (MAX_VALUE + 1) / radix'.
# Line 760  public final class Integer extends Numbe Line 760  public final class Integer extends Numbe
760      while (index < len)      while (index < len)
761        {        {
762          if (val < 0 || val > max)          if (val < 0 || val > max)
763            throw new NumberFormatException();            throw new NumberFormatException("number overflow (pos=" + index + ") : " + str);
764    
765          ch = Character.digit(str.charAt(index++), radix);          ch = Character.digit(str.charAt(index++), radix);
766          val = val * radix + ch;          val = val * radix + ch;
767          if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE)))          if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE)))
768            throw new NumberFormatException();            throw new NumberFormatException("invalid character at position " + index + " in " + str);
769        }        }
770      return isNeg ? -val : val;      return isNeg ? -val : val;
771    }    }

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

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