try to make mp3decoder compile
[IRC.git] / Robust / src / ClassLibrary / SSJava / Long.java
1 /* Long.java -- object wrapper for long
2    Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37
38
39 package java.lang;
40
41 /**
42  * Instances of class <code>Long</code> represent primitive
43  * <code>long</code> values.
44  *
45  * Additionally, this class provides various helper functions and variables
46  * related to longs.
47  *
48  * @author Paul Fisher
49  * @author John Keiser
50  * @author Warren Levy
51  * @author Eric Blake (ebb9@email.byu.edu)
52  * @author Tom Tromey (tromey@redhat.com)
53  * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
54  * @author Ian Rogers
55  * @since 1.0
56  * @status updated to 1.5
57  */
58 public final class Long //extends Number implements Comparable<Long>
59 {
60   /**
61    * Compatible with JDK 1.0.2+.
62    */
63   private static final long serialVersionUID = 4290774380558885855L;
64
65   /**
66    * The minimum value a <code>long</code> can represent is
67    * -9223372036854775808L (or -2<sup>63</sup>).
68    */
69   public static final long MIN_VALUE = 0x8000000000000000L;
70
71   /**
72    * The maximum value a <code>long</code> can represent is
73    * 9223372036854775807 (or 2<sup>63</sup> - 1).
74    */
75   public static final long MAX_VALUE = 0x7fffffffffffffffL;
76
77   /**
78    * The primitive type <code>long</code> is represented by this
79    * <code>Class</code> object.
80    * @since 1.1
81    */
82   //public static final Class<Long> TYPE = (Class<Long>) VMClassLoader.getPrimitiveClass ('J');
83
84   /**
85    * The number of bits needed to represent a <code>long</code>.
86    * @since 1.5
87    */
88   public static final int SIZE = 64;
89
90   // This caches some Long values, and is used by boxing
91   // conversions via valueOf().  We cache at least -128..127;
92   // these constants control how much we actually cache.
93   private static final int MIN_CACHE = -128;
94   private static final int MAX_CACHE = 127;
95   private static final Long[] longCache = new Long[MAX_CACHE - MIN_CACHE + 1];
96   static
97   {
98     for (int i=MIN_CACHE; i <= MAX_CACHE; i++)
99       longCache[i - MIN_CACHE] = new Long(i);
100   }
101
102   /**
103    * The immutable value of this Long.
104    *
105    * @serial the wrapped long
106    */
107   private final long value;
108
109   /**
110    * Create a <code>Long</code> object representing the value of the
111    * <code>long</code> argument.
112    *
113    * @param value the value to use
114    */
115   public Long(long value)
116   {
117     this.value = value;
118   }
119
120   /**
121    * Create a <code>Long</code> object representing the value of the
122    * argument after conversion to a <code>long</code>.
123    *
124    * @param s the string to convert
125    * @throws NumberFormatException if the String does not contain a long
126    * @see #valueOf(String)
127    */
128   public Long(String s)
129   {
130     value = parseLong(s, 10, false);
131   }
132
133   /**
134    * Return the size of a string large enough to hold the given number
135    *
136    * @param num the number we want the string length for (must be positive)
137    * @param radix the radix (base) that will be used for the string
138    * @return a size sufficient for a string of num
139    */
140   private static int stringSize(long num, int radix) {
141     int exp;
142     if (radix < 4)
143       {
144         exp = 1;
145       }
146     else if (radix < 8)
147       {
148         exp = 2;
149       }
150     else if (radix < 16)
151       {
152         exp = 3;
153       }
154     else if (radix < 32)
155       {
156         exp = 4;
157       }
158     else
159       {
160         exp = 5;
161       }
162     int size=0;
163     do
164       {
165         num >>>= exp;
166         size++;
167       }
168     while(num != 0);
169     return size;
170   }
171
172   /**
173    * Converts the <code>long</code> to a <code>String</code> using
174    * the specified radix (base). If the radix exceeds
175    * <code>Character.MIN_RADIX</code> or <code>Character.MAX_RADIX</code>, 10
176    * is used instead. If the result is negative, the leading character is
177    * '-' ('\\u002D'). The remaining characters come from
178    * <code>Character.forDigit(digit, radix)</code> ('0'-'9','a'-'z').
179    *
180    * @param num the <code>long</code> to convert to <code>String</code>
181    * @param radix the radix (base) to use in the conversion
182    * @return the <code>String</code> representation of the argument
183    */
184   /*public static String toString(long num, int radix)
185   {
186     if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
187       radix = 10;
188
189     // Is the value negative?
190     boolean isNeg = num < 0;
191
192     // Is the string a single character?
193     if (!isNeg && num < radix)
194       return new String(digits, (int)num, 1, true);
195
196     // Compute string size and allocate buffer
197     // account for a leading '-' if the value is negative
198     int size;
199     int i;
200     char[] buffer;
201     if (isNeg)
202       {
203         num = -num;
204
205         // When the value is MIN_VALUE, it overflows when made positive
206         if (num < 0)
207           {
208             i = size = stringSize(MAX_VALUE, radix) + 2;
209             buffer = new char[size];
210             buffer[--i] = digits[(int) (-(num + radix) % radix)];
211             num = -(num / radix);
212           }
213         else
214           {
215             i = size = stringSize(num, radix) + 1;
216             buffer = new char[size];
217           }
218       }
219     else
220       {
221         i = size = stringSize(num, radix);
222         buffer = new char[size];
223       }
224
225     do
226       {
227         buffer[--i] = digits[(int) (num % radix)];
228         num /= radix;
229       }
230     while (num > 0);
231
232     if (isNeg)
233       buffer[--i] = '-';
234
235     // Package constructor avoids an array copy.
236     return new String(buffer, i, size - i, true);
237   }*/
238
239   /**
240    * Converts the <code>long</code> to a <code>String</code> assuming it is
241    * unsigned in base 16.
242    *
243    * @param l the <code>long</code> to convert to <code>String</code>
244    * @return the <code>String</code> representation of the argument
245    */
246   /*public static String toHexString(long l)
247   {
248     return toUnsignedString(l, 4);
249   }*/
250
251   /**
252    * Converts the <code>long</code> to a <code>String</code> assuming it is
253    * unsigned in base 8.
254    *
255    * @param l the <code>long</code> to convert to <code>String</code>
256    * @return the <code>String</code> representation of the argument
257    */
258   /*public static String toOctalString(long l)
259   {
260     return toUnsignedString(l, 3);
261   }*/
262
263   /**
264    * Converts the <code>long</code> to a <code>String</code> assuming it is
265    * unsigned in base 2.
266    *
267    * @param l the <code>long</code> to convert to <code>String</code>
268    * @return the <code>String</code> representation of the argument
269    */
270   /*public static String toBinaryString(long l)
271   {
272     return toUnsignedString(l, 1);
273   }*/
274
275   /**
276    * Converts the <code>long</code> to a <code>String</code> and assumes
277    * a radix of 10.
278    *
279    * @param num the <code>long</code> to convert to <code>String</code>
280    * @return the <code>String</code> representation of the argument
281    * @see #toString(long, int)
282    */
283   public static String toString(long num)
284   {
285     //return toString(num, 10);
286     return String.valueOf(num);
287   }
288
289   /**
290    * Converts the specified <code>String</code> into an <code>int</code>
291    * using the specified radix (base). The string must not be <code>null</code>
292    * or empty. It may begin with an optional '-', which will negate the answer,
293    * provided that there are also valid digits. Each digit is parsed as if by
294    * <code>Character.digit(d, radix)</code>, and must be in the range
295    * <code>0</code> to <code>radix - 1</code>. Finally, the result must be
296    * within <code>MIN_VALUE</code> to <code>MAX_VALUE</code>, inclusive.
297    * Unlike Double.parseDouble, you may not have a leading '+'; and 'l' or
298    * 'L' as the last character is only valid in radices 22 or greater, where
299    * it is a digit and not a type indicator.
300    *
301    * @param str the <code>String</code> to convert
302    * @param radix the radix (base) to use in the conversion
303    * @return the <code>String</code> argument converted to <code>long</code>
304    * @throws NumberFormatException if <code>s</code> cannot be parsed as a
305    *         <code>long</code>
306    */
307   public static long parseLong(String str, int radix)
308   {
309     return parseLong(str, radix, false);
310   }
311
312   /**
313    * Converts the specified <code>String</code> into a <code>long</code>.
314    * This function assumes a radix of 10.
315    *
316    * @param s the <code>String</code> to convert
317    * @return the <code>int</code> value of <code>s</code>
318    * @throws NumberFormatException if <code>s</code> cannot be parsed as a
319    *         <code>long</code>
320    * @see #parseLong(String, int)
321    */
322   public static long parseLong(String s)
323   {
324     return parseLong(s, 10, false);
325   }
326
327   /**
328    * Creates a new <code>Long</code> object using the <code>String</code>
329    * and specified radix (base).
330    *
331    * @param s the <code>String</code> to convert
332    * @param radix the radix (base) to convert with
333    * @return the new <code>Long</code>
334    * @throws NumberFormatException if <code>s</code> cannot be parsed as a
335    *         <code>long</code>
336    * @see #parseLong(String, int)
337    */
338   public static Long valueOf(String s, int radix)
339   {
340     return valueOf(parseLong(s, radix, false));
341   }
342
343   /**
344    * Creates a new <code>Long</code> object using the <code>String</code>,
345    * assuming a radix of 10.
346    *
347    * @param s the <code>String</code> to convert
348    * @return the new <code>Long</code>
349    * @throws NumberFormatException if <code>s</code> cannot be parsed as a
350    *         <code>long</code>
351    * @see #Long(String)
352    * @see #parseLong(String)
353    */
354   public static Long valueOf(String s)
355   {
356     return valueOf(parseLong(s, 10, false));
357   }
358
359   /**
360    * Returns a <code>Long</code> object wrapping the value.
361    *
362    * @param val the value to wrap
363    * @return the <code>Long</code>
364    * @since 1.5
365    */
366   public static Long valueOf(long val)
367   {
368     if (val < MIN_CACHE || val > MAX_CACHE)
369       return new Long(val);
370     else
371       return longCache[((int)val) - MIN_CACHE];
372   }
373
374   /**
375    * Convert the specified <code>String</code> into a <code>Long</code>.
376    * The <code>String</code> may represent decimal, hexadecimal, or
377    * octal numbers.
378    *
379    * <p>The extended BNF grammar is as follows:<br>
380    * <pre>
381    * <em>DecodableString</em>:
382    *      ( [ <code>-</code> ] <em>DecimalNumber</em> )
383    *    | ( [ <code>-</code> ] ( <code>0x</code> | <code>0X</code>
384    *              | <code>#</code> ) <em>HexDigit</em> { <em>HexDigit</em> } )
385    *    | ( [ <code>-</code> ] <code>0</code> { <em>OctalDigit</em> } )
386    * <em>DecimalNumber</em>:
387    *        <em>DecimalDigit except '0'</em> { <em>DecimalDigit</em> }
388    * <em>DecimalDigit</em>:
389    *        <em>Character.digit(d, 10) has value 0 to 9</em>
390    * <em>OctalDigit</em>:
391    *        <em>Character.digit(d, 8) has value 0 to 7</em>
392    * <em>DecimalDigit</em>:
393    *        <em>Character.digit(d, 16) has value 0 to 15</em>
394    * </pre>
395    * Finally, the value must be in the range <code>MIN_VALUE</code> to
396    * <code>MAX_VALUE</code>, or an exception is thrown. Note that you cannot
397    * use a trailing 'l' or 'L', unlike in Java source code.
398    *
399    * @param str the <code>String</code> to interpret
400    * @return the value of the String as a <code>Long</code>
401    * @throws NumberFormatException if <code>s</code> cannot be parsed as a
402    *         <code>long</code>
403    * @throws NullPointerException if <code>s</code> is null
404    * @since 1.2
405    */
406   public static Long decode(String str)
407   {
408     return valueOf(parseLong(str, 10, true));
409   }
410
411   /**
412    * Return the value of this <code>Long</code> as a <code>byte</code>.
413    *
414    * @return the byte value
415    */
416   public byte byteValue()
417   {
418     return (byte) value;
419   }
420
421   /**
422    * Return the value of this <code>Long</code> as a <code>short</code>.
423    *
424    * @return the short value
425    */
426   public short shortValue()
427   {
428     return (short) value;
429   }
430
431   /**
432    * Return the value of this <code>Long</code> as an <code>int</code>.
433    *
434    * @return the int value
435    */
436   public int intValue()
437   {
438     return (int) value;
439   }
440
441   /**
442    * Return the value of this <code>Long</code>.
443    *
444    * @return the long value
445    */
446   public long longValue()
447   {
448     return value;
449   }
450
451   /**
452    * Return the value of this <code>Long</code> as a <code>float</code>.
453    *
454    * @return the float value
455    */
456   public float floatValue()
457   {
458     return value;
459   }
460
461   /**
462    * Return the value of this <code>Long</code> as a <code>double</code>.
463    *
464    * @return the double value
465    */
466   public double doubleValue()
467   {
468     return value;
469   }
470
471   /**
472    * Converts the <code>Long</code> value to a <code>String</code> and
473    * assumes a radix of 10.
474    *
475    * @return the <code>String</code> representation
476    */
477   public String toString()
478   {
479     //return toString(value, 10);
480     return String.valueOf(value);
481   }
482
483   /**
484    * Return a hashcode representing this Object. <code>Long</code>'s hash
485    * code is calculated by <code>(int) (value ^ (value &gt;&gt; 32))</code>.
486    *
487    * @return this Object's hash code
488    */
489   public int hashCode()
490   {
491     return (int) (value ^ (value >>> 32));
492   }
493
494   /**
495    * Returns <code>true</code> if <code>obj</code> is an instance of
496    * <code>Long</code> and represents the same long value.
497    *
498    * @param obj the object to compare
499    * @return whether these Objects are semantically equal
500    */
501   public boolean equals(Object obj)
502   {
503     return obj instanceof Long && value == ((Long) obj).value;
504   }
505
506   /**
507    * Get the specified system property as a <code>Long</code>. The
508    * <code>decode()</code> method will be used to interpret the value of
509    * the property.
510    *
511    * @param nm the name of the system property
512    * @return the system property as a <code>Long</code>, or null if the
513    *         property is not found or cannot be decoded
514    * @throws SecurityException if accessing the system property is forbidden
515    * @see System#getProperty(String)
516    * @see #decode(String)
517    */
518   public static Long getLong(String nm)
519   {
520     return getLong(nm, null);
521   }
522
523   /**
524    * Get the specified system property as a <code>Long</code>, or use a
525    * default <code>long</code> value if the property is not found or is not
526    * decodable. The <code>decode()</code> method will be used to interpret
527    * the value of the property.
528    *
529    * @param nm the name of the system property
530    * @param val the default value
531    * @return the value of the system property, or the default
532    * @throws SecurityException if accessing the system property is forbidden
533    * @see System#getProperty(String)
534    * @see #decode(String)
535    */
536   public static Long getLong(String nm, long val)
537   {
538     Long result = getLong(nm, null);
539     return result == null ? valueOf(val) : result;
540   }
541
542   /**
543    * Get the specified system property as a <code>Long</code>, or use a
544    * default <code>Long</code> value if the property is not found or is
545    * not decodable. The <code>decode()</code> method will be used to
546    * interpret the value of the property.
547    *
548    * @param nm the name of the system property
549    * @param def the default value
550    * @return the value of the system property, or the default
551    * @throws SecurityException if accessing the system property is forbidden
552    * @see System#getProperty(String)
553    * @see #decode(String)
554    */
555   public static Long getLong(String nm, Long def)
556   {
557     if (nm == null || "".equals(nm))
558       return def;
559     nm = null;//System.getProperty(nm);
560     if (nm == null)
561       return def;
562     /*try
563       {
564         return decode(nm);
565       }
566     catch (NumberFormatException e)
567       {
568         return def;
569       }*/
570   }
571
572   /**
573    * Compare two Longs numerically by comparing their <code>long</code>
574    * values. The result is positive if the first is greater, negative if the
575    * second is greater, and 0 if the two are equal.
576    *
577    * @param l the Long to compare
578    * @return the comparison
579    * @since 1.2
580    */
581   public int compareTo(Long l)
582   {
583     if (value == l.value)
584       return 0;
585     // Returns just -1 or 1 on inequality; doing math might overflow the long.
586     return value > l.value ? 1 : -1;
587   }
588
589   /**
590    * Return the number of bits set in x.
591    * @param x value to examine
592    * @since 1.5
593    */
594   public static int bitCount(long x)
595   {
596     // Successively collapse alternating bit groups into a sum.
597     x = ((x >> 1) & 0x5555555555555555L) + (x & 0x5555555555555555L);
598     x = ((x >> 2) & 0x3333333333333333L) + (x & 0x3333333333333333L);
599     int v = (int) ((x >>> 32) + x);
600     v = ((v >> 4) & 0x0f0f0f0f) + (v & 0x0f0f0f0f);
601     v = ((v >> 8) & 0x00ff00ff) + (v & 0x00ff00ff);
602     return ((v >> 16) & 0x0000ffff) + (v & 0x0000ffff);
603   }
604
605   /**
606    * Rotate x to the left by distance bits.
607    * @param x the value to rotate
608    * @param distance the number of bits by which to rotate
609    * @since 1.5
610    */
611   public static long rotateLeft(long x, int distance)
612   {
613     // This trick works because the shift operators implicitly mask
614     // the shift count.
615     return (x << distance) | (x >>> - distance);
616   }
617
618   /**
619    * Rotate x to the right by distance bits.
620    * @param x the value to rotate
621    * @param distance the number of bits by which to rotate
622    * @since 1.5
623    */
624   public static long rotateRight(long x, int distance)
625   {
626     // This trick works because the shift operators implicitly mask
627     // the shift count.
628     return (x << - distance) | (x >>> distance);
629   }
630
631   /**
632    * Find the highest set bit in value, and return a new value
633    * with only that bit set.
634    * @param value the value to examine
635    * @since 1.5
636    */
637   public static long highestOneBit(long value)
638   {
639     value |= value >>> 1;
640     value |= value >>> 2;
641     value |= value >>> 4;
642     value |= value >>> 8;
643     value |= value >>> 16;
644     value |= value >>> 32;
645     return value ^ (value >>> 1);
646   }
647
648   /**
649    * Return the number of leading zeros in value.
650    * @param value the value to examine
651    * @since 1.5
652    */
653   public static int numberOfLeadingZeros(long value)
654   {
655     value |= value >>> 1;
656     value |= value >>> 2;
657     value |= value >>> 4;
658     value |= value >>> 8;
659     value |= value >>> 16;
660     value |= value >>> 32;
661     return bitCount(~value);
662   }
663
664   /**
665    * Find the lowest set bit in value, and return a new value
666    * with only that bit set.
667    * @param value the value to examine
668    * @since 1.5
669    */
670   public static long lowestOneBit(long value)
671   {
672     // Classic assembly trick.
673     return value & - value;
674   }
675
676   /**
677    * Find the number of trailing zeros in value.
678    * @param value the value to examine
679    * @since 1.5
680    */
681   public static int numberOfTrailingZeros(long value)
682   {
683     return bitCount((value & -value) - 1);
684   }
685
686   /**
687    * Return 1 if x is positive, -1 if it is negative, and 0 if it is
688    * zero.
689    * @param x the value to examine
690    * @since 1.5
691    */
692   public static int signum(long x)
693   {
694     return (int) ((x >> 63) | (-x >>> 63));
695
696     // The LHS propagates the sign bit through every bit in the word;
697     // if X < 0, every bit is set to 1, else 0.  if X > 0, the RHS
698     // negates x and shifts the resulting 1 in the sign bit to the
699     // LSB, leaving every other bit 0.
700
701     // Hacker's Delight, Section 2-7
702   }
703
704   /**
705    * Reverse the bytes in val.
706    * @since 1.5
707    */
708   /*public static long reverseBytes(long val)
709   {
710     int hi = Integer.reverseBytes((int) val);
711     int lo = Integer.reverseBytes((int) (val >>> 32));
712     return (((long) hi) << 32) | lo;
713   }*/
714
715   /**
716    * Reverse the bits in val.
717    * @since 1.5
718    */
719   /*public static long reverse(long val)
720   {
721     long hi = Integer.reverse((int) val) & 0xffffffffL;
722     long lo = Integer.reverse((int) (val >>> 32)) & 0xffffffffL;
723     return (hi << 32) | lo;
724   }*/
725
726   /**
727    * Helper for converting unsigned numbers to String.
728    *
729    * @param num the number
730    * @param exp log2(digit) (ie. 1, 3, or 4 for binary, oct, hex)
731    */
732   /*private static String toUnsignedString(long num, int exp)
733   {
734     // Compute string length
735     int size = 1;
736     long copy = num >>> exp;
737     while (copy != 0)
738       {
739         size++;
740         copy >>>= exp;
741       }
742     // Quick path for single character strings
743     if (size == 1)
744       return new String(digits, (int)num, 1, true);
745
746     // Encode into buffer
747     int mask = (1 << exp) - 1;
748     char[] buffer = new char[size];
749     int i = size;
750     do
751       {
752         buffer[--i] = digits[(int) num & mask];
753         num >>>= exp;
754       }
755     while (num != 0);
756
757     // Package constructor avoids an array copy.
758     return new String(buffer, i, size - i, true);
759   }*/
760
761   /**
762    * Helper for parsing longs.
763    *
764    * @param str the string to parse
765    * @param radix the radix to use, must be 10 if decode is true
766    * @param decode if called from decode
767    * @return the parsed long value
768    * @throws NumberFormatException if there is an error
769    * @throws NullPointerException if decode is true and str is null
770    * @see #parseLong(String, int)
771    * @see #decode(String)
772    */
773   private static long parseLong(String str, int radix, boolean decode)
774   {
775     if (! decode && str == null)
776       throw new /*NumberFormat*/Exception("NumberFormatException");
777     int index = 0;
778     int len = str.length();
779     boolean isNeg = false;
780     if (len == 0)
781       throw new /*NumberFormat*/Exception("NumberFormatException");
782     int ch = str.charAt(index);
783     if (ch == '-')
784       {
785         if (len == 1)
786           throw new /*NumberFormat*/Exception("NumberFormatException");
787         isNeg = true;
788         ch = str.charAt(++index);
789       }
790     if (decode)
791       {
792         if (ch == '0')
793           {
794             if (++index == len)
795               return 0;
796             if ((str.charAt(index) & ~('x' ^ 'X')) == 'X')
797               {
798                 radix = 16;
799                 index++;
800               }
801             else
802               radix = 8;
803           }
804         else if (ch == '#')
805           {
806             radix = 16;
807             index++;
808           }
809       }
810     if (index == len)
811       throw new /*NumberFormat*/Exception("NumberFormatException");
812
813     long max = MAX_VALUE / radix;
814     // We can't directly write `max = (MAX_VALUE + 1) / radix'.
815     // So instead we fake it.
816     if (isNeg && MAX_VALUE % radix == radix - 1)
817       ++max;
818
819     long val = 0;
820     while (index < len)
821       {
822         if (val < 0 || val > max)
823           throw new /*NumberFormat*/Exception("NumberFormatException");
824
825         ch = Character.digit(str.charAt(index++), radix);
826         val = val * radix + ch;
827         if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE)))
828           throw new /*NumberFormat*/Exception("NumberFormatException");
829       }
830     return isNeg ? -val : val;
831   }
832 }