B2X | Converts a binary string to a hexadecimal string. |
C2D | Converts an ASCII character to an equivalent decimal string. |
C2X | Converts an ASCII character to an equivalent hexadecimal string. |
D2C | Converts a decimal string to an equivalent ASCII character. |
D2X | Converts a decimal string to a hexadecimal string. |
X2B | Converts a hexadecimal string to a binary string. |
X2C | Converts a hexadecimal string to an equivalent ASCII character. |
X2D | Converts a hexadecimal string to a decimal string. |
Converts a binary string to a hexadecimal string.
Synopsis
hex = B2X(binary)
Args
binary is the original number in binary format.
Returns
The original number in hexadecimal format.
Notes
Binary strings contain only the digits 0 and 1, and are numeric values expressed in base 2. Hexadecimal strings contain the digits 0 to 9, and the letters A to F, inclusive, and are numeric values expressed in base 16.
To increase readability, spaces may be included in a binary string to separate the digits into groups. Each such group must have a multiple of 4 binary digits, except for the first group. If the number of binary digits in the first group is not a multiple of 4, that group is padded at the left with up to three leading zeros, to make it a multiple of four. Spaces can occur only between groups, not as leading or trailing characters. Use STRIP() to remove any leading/trailing spaces.
Each group of four binary digits is translated into a hexadecimal digit in the result string. There will be no extra spaces in the result, and the hexadecimal digits of A to F are in upper case.
The original number is not altered.
Examples
Example use | Return value |
B2X('0010 01011100 0011') |
'26C3' |
B2X('10 0101 11111111') |
'26FF' |
B2X('0100100 0011') |
'243' |
See also
Converts an ASCII character to an equivalent decimal string.
Synopsis
decimal = C2D(chars, length)
Args
chars is the ASCII character.
If length is specified, it indicates the number of rightmost "bytes" in chars to be converted, and chars is assumed to be in two’s complement format. If length is larger than the actual number of bytes in chars, chars is sign-extended on the left. (ie. chars is padded with either 'FF' or '00' bytes on the left-hand side, depending upon whether bit 7 of the leftmost byte is set or clear). If length is too short, only the length rightmost bytes in chars are considered. If length is omitted, then chars is regarded as an unsigned ASCII character.
Returns
The decimal string that is equivalent to the ASCII character.
Notes
This function is very dependent on the character set that your computer is using.
The original ASCII character is not altered.
Examples
Example use | Return value |
C2D('a') |
97 |
C2D('09'x) /* Not printable as ASCII, so shown as hex */ |
9 |
C2D('FF81'x) |
65409 |
C2D('FF81'x, 2) |
-127 |
See also
Converts an ASCII character to an equivalent hexadecimal string.
Synopsis
hex = C2X(chars)
Args
chars is the ASCII character.
Returns
The hexadecimal string that is equivalent to the ASCII character.
Notes
Each ASCII "byte" is translated into a hexadecimal digit in the converted string. There will be no extra spaces in the result, and the hexadecimal digits of A to F are in upper case.
This function is very dependent on the character set that your computer is using.
The original ASCII character is not altered.
Examples
Example use | Return value |
C2X('A') |
'41' |
C2X('jkl') |
'6A6B6C' |
See also
Converts a decimal string to an equivalent ASCII character(s).
Synopsis
ascii = D2C(decimal, length)
Args
decimal is the decimal string.
length indicates the number of "bytes" desired in the resulting ASCII character. If length is specified, then decimal is assumed to be a signed number (ie, could be negative). The converted ASCII character will be sign-extended on the left to pad out to length. (ie. The result is padded with either 'FF' or '00' bytes on the left-hand side, depending upon whether bit 7 of the leftmost byte is set or clear). If length is too short to produce an equivalent ASCII character from decimal, then this raises a SYNTAX error. If length is omitted, then decimal must be an unsigned (ie, positive) number.
Returns
The ASCII character that is equivalent to the decimal string.
Notes
This function is very dependent on the character set that your computer is using.
The original decimal string is not altered.
Examples
Example use | Return value |
D2C(0) |
'' /* An empty string */ |
D2C(65) |
'A' |
D2C(66) |
'B' |
D2C(-127, 4) |
'FFFFFF81'x /* Not printable as ASCII, so shown as hex */ |
See also
Converts a decimal string to a hexadecimal string.
Synopsis
hex = D2X(decimal, length)
Args
decimal is the decimal string.
length indicates the number of "bytes" desired in the resulting hexadecimal string. If length is specified, then decimal is assumed to be a signed number (ie, could be negative). The converted hex string will either be truncated to fit length (if too long), or be sign-extended on the left to pad out to length. (ie. The result is padded with either 'FF' or '00' bytes on the left-hand side, depending upon whether bit 7 of the leftmost byte is set or clear). If length is omitted, then decimal must be an unsigned (ie, positive) number.
Returns
The hexadecimal string that is equivalent to the decimal string.
Notes
The original decimal string is not altered.
Examples
Example use | Return value |
D2X(9) |
9 |
D2X(48) |
30 |
D2X(129) |
81 |
D2X(129, 1) |
1 /* Truncated */ |
D2X(-127,4) |
FF81 /* Sign-extended */ |
See also
Converts a hexadecimal string to a binary string.
Synopsis
binary = X2B(hex)
Args
hex is the hexadecimal string.
Returns
The binary string that is equivalent to the hexadecimal string.
Notes
Binary strings contain only the digits 0 and 1, and are numeric values expressed in base 2. Hexadecimal strings contain the digits 0 to 9, and the letters A to F, inclusive, and are numeric values expressed in base 16.
To increase readability, spaces may be included in a hexadecimal string to separate the digits into groups. Each such group must have a multiple of 2, 4, 8, or 16 binary digits, except for the first group. If the number of binary digits in the first group is not a multiple of 2, that group is padded at the left with a leading zero, to make it a multiple of 2. Spaces can occur only between groups, not as leading or trailing characters. Use STRIP() to remove any leading/trailing spaces.
Each hexadecimal digit is converted to a group of four binary digits in the result string. There will be no extra spaces in the result.
The original hexadecimal string is not altered.
Examples
Example use | Return value |
X2B('CF') |
'11001111' |
X2B('41') |
'01000001' |
X2B('FF FF') |
'1111111111111111' |
See also
Converts a hexadecimal string to an equivalent ASCII character.
Synopsis
ascii = X2C(hex)
Args
hex is the original number in hexadecimal format.
Returns
The ASCII character that is equivalent to the hexadecimal string.
Notes
The original hexadecimal string is not altered.
Examples
Example use | Return value |
X2C('46 6f 6f') |
'foo' |
X2C('F') |
'0F'x /* Not a printable ASCII char, so shown as hex */ |
X2C('0d') |
'0D'x /* Not a printable ASCII char, so shown as hex. This would actually produce a linefeed */ |
See also
Converts a hexadecimal string to a decimal string.
Synopsis
decimal = X2D(hex, length)
Args
hex is the hexadecimal string.
If length is specified, it indicates the number of rightmost digits in hex to be converted, and hex is assumed to be in two’s complement format. If length is larger than the actual number of characters in hex, hex is sign-extended on the left. (ie. hex is padded with either 'F' or '0' characters on the left-hand side, depending upon whether bit 4 of the leftmost digit is set or clear). If length is too short, only the length rightmost digits in hex are considered. If length is omitted, then hex is regarded as an unsigned hexadecimal value.
Returns
The decimal string that is equivalent to the hexadecimal string.
Notes
The original hexadecimal string is not altered.
Examples
Example use | Return value |
X2D('1A') |
26 |
X2D('ffff') |
65535 |
X2D('ffff', 5) |
65535 |
X2D('ffff', 4) |
-1 |
X2D('03 24') |
792 |
See also