public long parseLong( long bitMask, boolean signed ) throws IOException {
        int sign = 1;

        int c = nextNonWhitespace();
        position(-1);
             
        if( c == '+' ) {
            // Unclear if whitespace is allowed here or not
            c = read();
        } else if( c == '-' ) {
            sign = -1;
            // Unclear if whitespace is allowed here or not
            c = read();
        }
 
        Long result = null;           
        if( c == '0' ) {
            int d = read();
            if( d == 'x' || d == 'X' ) {
                result = parseIntString(16, "hexidecimal");
                result = signExtend(result, bitMask, signed) * sign;
            } else if( d == 'b' || d == 'B' ) {
                result = parseIntString(2, "binary");
                result = signExtend(result, bitMask, signed) * sign;
            } else {
                pushBack(d);
            }     
        } else if( c == '\'' ) {
            result = parseCharLiteral() * sign;
        }
        
        if( result == null ) {
            // If we got here then we didn't use the original 
            // char we read at the top of the method.
            pushBack(c);
 
            // Else read the number while we have digits
            result = parseIntString(10, "decimal") * sign;            
        }
        
        // Verify that it fits the requirements    
        checkBits(result, bitMask, signed);            
 
        return result;
    }