Re: Системы счисления
От: DK3981 Россия  
Дата: 23.05.06 13:02
Оценка:
DD>java.lang.NumberFormatException: For input string: "FFFFFFFFFFFFFFFF"

DD>
DD>// обратный перевод - в следущей строке вылетает Exception
DD>long a = Long.decode("0x" + strBuffer.toString());
DD>strBuffer.delete(0, strBuffer.length());
DD>strBuffer.append(Long.toString(a));
DD>


Читаем документацию:

The sequence of characters following an (optional) negative sign and/or radix specifier ("0x", "0X", "#", or leading zero) is parsed as by the Long.parseLong method with the indicated radix (10, 16, or 8). This sequence of characters must represent a positive value or a NumberFormatException will be thrown. The result is negated if first character of the specified String is the minus sign. No whitespace characters are permitted in the String.

Для отрицательных чисел надо использовать знак — в начале: decode("-0x64") даст в результате -100.
... << RSDN@Home 1.1.4 stable SR1 rev. 568>>
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.