public final class NumeralSystemHelper extends Object
Modifier and Type | Method | Description |
---|---|---|
static String |
convert(int value,
int to) |
Returns a string representation of the first argument in the radix specified by the third argument from the radix
specified by the second argument.
|
static String |
convert(String valueStr,
int from,
int to) |
Returns a string representation of the first argument in the radix specified by the third argument from the radix
specified by the second argument.
|
static String |
convertBinaryToDecimal(String binaryStr) |
Returns a string representation of the binary value as an unsigned integer in base 10.
|
static String |
convertBinaryToHexadecimal(String binaryStr) |
Returns a string representation of the binary value as an unsigned integer in base 16.
|
static String |
convertBinaryToOctal(String binaryStr) |
Returns a string representation of the binary value as an unsigned integer in base 8.
|
static String |
convertDecimalToBinary(int integer) |
Returns a string representation of the integer argument as an unsigned integer in base 2.
|
static String |
convertDecimalToHexadecimal(int integer) |
Returns a string representation of the integer argument as an unsigned integer in base 16.
|
static String |
convertDecimalToOctal(int integer) |
Returns a string representation of the integer argument as an unsigned integer in base 8.
|
static String |
convertHexadecimalToBinary(String hexStr) |
Returns a string representation of the hexadecimal value as an unsigned integer in base 2.
|
static String |
convertHexadecimalToDecimal(String hexStr) |
Returns a string representation of the hexadecimal value as an unsigned integer in base 10.
|
static String |
convertHexadecimalToOctal(String hexStr) |
Returns a string representation of the hexadecimal value as an unsigned integer in base 8.
|
static String |
convertOctalToBinary(String octalStr) |
Returns a string representation of the octal value as an unsigned integer in base 2.
|
static String |
convertOctalToDecimal(String octalStr) |
Returns a string representation of the octal value as an unsigned integer in base 10.
|
static String |
convertOctalToHexadecimal(String octalStr) |
Returns a string representation of the octal value as an unsigned integer in base 16.
|
public static String convert(String valueStr, int from, int to)
Character.MIN_RADIX
or larger than Character.MAX_RADIX
, then the
radix 10 is used instead.
-
'.
If the first argument is not negative, no sign character appears in the result.
0
'; otherwise, the first character of the
representation of the magnitude will not be the zero character. The following ASCII characters are used as digits:
0123456789abcdefghijklmnopqrstuvwxyz
0
' through '9
' and 'a
' through 'z
'. If radix is
N
, then the first N
of these characters are used as
radix-N
digits in the order shown. Thus, the digits for hexadecimal (radix 16) are
0123456789abcdef
. If uppercase letters are desired, the String.toUpperCase()
method may be
called on the result.valueStr
- a string to be converted to the desired system.from
- the radix to which the string representation is in.to
- the radix to use in the string representation.public static String convert(int value, int to)
convert(Integer.toString(value), 10, to)
value
- an integer to be converted to the desired system.to
- the radix to use in the string representation.convert(String, int, int)
public static String convertDecimalToHexadecimal(int integer)
integer
- an integer to be converted to a string.public static String convertDecimalToBinary(int integer)
integer
- an integer to be converted to a string.public static String convertDecimalToOctal(int integer)
integer
- an integer to be converted to a string.public static String convertBinaryToHexadecimal(String binaryStr)
binaryStr
- a binary value to be converted to a hexadecimal string.public static String convertBinaryToOctal(String binaryStr)
binaryStr
- a binary value to be converted to an octal string.public static String convertBinaryToDecimal(String binaryStr)
binaryStr
- a binary value to be converted to a decimal string.public static String convertHexadecimalToBinary(String hexStr)
hexStr
- a hexadecimal value to be converted to a binary string.public static String convertHexadecimalToOctal(String hexStr)
hexStr
- a hexadecimal value to be converted to an octal string.public static String convertHexadecimalToDecimal(String hexStr)
hexStr
- a hexadecimal value to be converted to a decimal string.public static String convertOctalToBinary(String octalStr)
octalStr
- an octal value to be converted to a binary string.public static String convertOctalToHexadecimal(String octalStr)
octalStr
- an octal value to be converted to a hexadecimal string.public static String convertOctalToDecimal(String octalStr)
octalStr
- an octal value to be converted to a decimal string.Copyright © 2008, 2018, Shaiksphere Inc.. All rights reserved.