Methods
-
<static> convert(value, from [, 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.
For radixes above
10, the letters of the alphabet indicate numerals greater than9. For example, for hexadecimal numbers (base 16),athroughfare used.If the third argument is not specified, the preferred radix is assumed to be 10.
If the first argument is negative, the sign is preserved. This is the case even if the radix is
2; the string returned is the positive binary representation of the first argument preceded by a-sign, not the two's complement of the first argument.If the first argument is not a whole number, the 'dot' sign is used to separate the decimal places.
Parameters:
Name Type Argument Default Description valueObject to be converted to the desired system.
fromNumber the radix to which the string representation is in.
toNumber <optional>
10 the radix to use in the string representation.
- Since:
-
- 3.1.0
Throws:
-
If radix is not between
2and36. - Type
- RangeError
Returns:
a string representation of the argument in the specified radix.
- Type
- String
-
<static> convertBinaryToDecimal(obj)
-
Returns a string representation of the binary value in base 10.
Parameters:
Name Type Description objObject binary value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in decimal (base 10).
- Type
- String
-
<static> convertBinaryToHexadecimal(obj)
-
Returns a string representation of the binary value in base 16.
Parameters:
Name Type Description objObject binary value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in hexadecimal (base 16).
- Type
- String
-
<static> convertBinaryToOctal(obj)
-
Returns a string representation of the binary value in base 8.
Parameters:
Name Type Description objObject binary value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in octal (base 8).
- Type
- String
-
<static> convertDecimalToBinary(obj)
-
Returns a string representation of the decimal value in base 2.
Parameters:
Name Type Description objObject decimal value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in binary (base 2).
- Type
- String
-
<static> convertDecimalToHexadecimal(obj)
-
Returns a string representation of the decimal value in base 16.
Parameters:
Name Type Description objObject decimal value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in hexadecimal (base 16).
- Type
- String
-
<static> convertDecimalToOctal(obj)
-
Returns a string representation of the decimal value in base 8.
Parameters:
Name Type Description objObject decimal value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in octal (base 8).
- Type
- String
-
<static> convertHexadecimalToBinary(obj)
-
Returns a string representation of the hexadecimal value in base 2.
Parameters:
Name Type Description objObject hexadecimal value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in binary (base 2).
- Type
- String
-
<static> convertHexadecimalToDecimal(obj)
-
Returns a string representation of the hexadecimal value in base 10.
Parameters:
Name Type Description objObject hexadecimal value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in decimal (base 10).
- Type
- String
-
<static> convertHexadecimalToOctal(obj)
-
Returns a string representation of the hexadecimal value in base 8.
Parameters:
Name Type Description objObject hexadecimal value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in octal (base 8).
- Type
- String
-
<static> convertOctalToBinary(obj)
-
Returns a string representation of the octal value in base 2.
Parameters:
Name Type Description objObject octal value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in binary (base 2).
- Type
- String
-
<static> convertOctalToDecimal(obj)
-
Returns a string representation of the octal value in base 10.
Parameters:
Name Type Description objObject octal value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in decimal (base 10).
- Type
- String
-
<static> convertOctalToHexadecimal(obj)
-
Returns a string representation of the octal value in base 16.
Parameters:
Name Type Description objObject octal value to be converted to a string.
- Since:
-
- 3.1.0
Returns:
the string representation in hexadecimal (base 16).
- Type
- String