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

Diff of /classpath/java/lang/Short.java

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

revision 1.13 by ericb, Mon Feb 25 01:36:03 2002 UTC revision 1.14 by ericb, Mon Feb 25 20:02:58 2002 UTC
# Line 150  public final class Short extends Number Line 150  public final class Short extends Number
150     */     */
151    public static short parseShort(String s, int radix)    public static short parseShort(String s, int radix)
152    {    {
153      int i = Integer.parseInt(s, radix);      int i = Integer.parseInt(s, radix, false);
154      if ((short) i != i)      if ((short) i != i)
155        throw new NumberFormatException();        throw new NumberFormatException();
156      return (short) i;      return (short) i;
# Line 209  public final class Short extends Number Line 209  public final class Short extends Number
209     * <em>DecimalDigit</em>:     * <em>DecimalDigit</em>:
210     *        <em>Character.digit(d, 16) has value 0 to 15</em>     *        <em>Character.digit(d, 16) has value 0 to 15</em>
211     * </pre>     * </pre>
212     * Note that you cannot decode MIN_VALUE, as the specification requires     * Finally, the value must be in the range <code>MIN_VALUE</code> to
213     * that the digits be parsed before negating the result, but 32768 will     * <code>MAX_VALUE</code>, or an exception is thrown.
    * not fit in a short.  
214     *     *
215     * @param s the <code>String</code> to interpret     * @param s the <code>String</code> to interpret
216     * @return the value of the String as a <code>Short</code>     * @return the value of the String as a <code>Short</code>
217     * @throws NumberFormatException if <code>s</code> cannot be parsed as a     * @throws NumberFormatException if <code>s</code> cannot be parsed as a
218     *         <code>short</code>     *         <code>short</code>
219     * @throws NullPointerException if s is null     * @throws NullPointerException if <code>s</code> is null
220     * @see Integer#decode(String)     * @see Integer#decode(String)
221     */     */
222    public static Short decode(String s)    public static Short decode(String s)
223    {    {
224      int i = (Integer.decode(s)).intValue();      int i = Integer.parseInt(s, 10, true);
225      if ((short) i != i)      if ((short) i != i)
226        throw new NumberFormatException();        throw new NumberFormatException();
227      return new Short((short) i);      return new Short((short) i);

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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