public long parseLong ( char [ ] arr , int start , int end ) { long x = 0 ; boolean negative = arr [ start ] == ' ' ; for ( int i = negative ? start + 1 : start ; i < end ; i ++ ) { // If constructing the largest negative number, this will overflow // to the largest negative number. This is OK since the negation of // the largest negative number is itself in two's complement. x = x * 10 + ( arr [ i ] - ' ' ) ; } // could replace conditional-move with multiplication of sign... not sure // which is faster. return negative ? - x : x ; }
belongs in number utils or charutil?