- All Implemented Interfaces:
Serializable
,Comparable<Radix>
,Constable
Represents a radix for number conversion.
The radix is the base of a number system.
This class represents the most common radices used in computer science:
The radix is the base of a number system.
This class represents the most common radices used in computer science:
Binary
(base 2)Octal
(base 8)Decimal
(base 10)Hexadecimal
(base 16)
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRepresents the binary radix (base 2) with the prefix0b
.Represents the decimal radix (base 10) with no prefix.Represents the hexadecimal radix (base 16) with the prefix0x
.Represents the octal radix (base 8) with the prefix0
. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull String
Returns the prefix for the radix used in string conversion.int
getRadix()
Returns the radix value.toString()
static Radix
Returns the enum constant of this class with the specified name.static Radix[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
BINARY
Represents the binary radix (base 2) with the prefix0b
. -
OCTAL
Represents the octal radix (base 8) with the prefix0
. -
DECIMAL
Represents the decimal radix (base 10) with no prefix. -
HEXADECIMAL
Represents the hexadecimal radix (base 16) with the prefix0x
.
-
-
Field Details
-
radix
private final int radixThe radix value. -
prefix
The prefix for the radix used in string conversion.
-
-
Constructor Details
-
Radix
Constructs a new radix with the given radix value and prefix.- Parameters:
radix
- The radix valueprefix
- The prefix for the radix- Throws:
IllegalArgumentException
- If the radix is less than or equal to 0NullPointerException
- If the prefix is null
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getRadix
public int getRadix()Returns the radix value.- Returns:
- The radix value
-
getPrefix
Returns the prefix for the radix used in string conversion.- Returns:
- The prefix for the radix
-
toString
-