B2X | Converts a binary string to a hexadecimal string. |
C2D | Converts an ASCII character to an equivalent decimal value. |
C2X | Converts an ASCII character to an equivalent hexadecimal value. |
D2C | Converts a decimal value 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.
hex = B2X(binary)
binary is the original number in binary format.
The original number in hexadecimal format.
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.
B2X('0010 01011100 0011') |
'26C3' |
B2X('10 0101 11111111') |
'26FF' |
B2X('0100100 0011') |
'243' |
Converts an ASCII character to an equivalent decimal value.
decimal = C2D(chars, length)
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'x or '00'x 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.
The decimal value that is equivalent to the ASCII character.
This function is very dependent on the character set that your computer is using.
The original ASCII character is not altered.
C2D('a') |
97 |
C2D('09'x) /* Not printable as ASCII, so shown as hex */ |
9 |
C2D('FF81'x) |
65409 |
C2D('FF81'x, 2) |
-127 |
Converts an ASCII character to an equivalent hexadecimal value.
hex = C2X(chars)
chars is the ASCII character.
The hexadecimal value that is equivalent to the ASCII character.
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.
C2X('A') |
'41' |
C2X('JKL') |
'6A6B6C' |
Converts a decimal value to an equivalent ASCII character.
ascii = D2C(decimal, length)
decimal is the decimal value.
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'x or '00'x 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.
The ASCII character that is equivalent to the decimal value.
This function is very dependent on the character set that your computer is using.
The original decimal value is not altered.
D2C(0) |
'' /* An empty string */ |
D2C(65) |
'A' |
D2C(66) |
'B' |
D2C(-127, 4) |
'FFFFFF81'x /* Not printable as ASCII, so shown as hex */ |
Converts a decimal value to a hexadecimal string.
hex = D2X(decimal, length)
decimal is the decimal value.
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'x or '00'x 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.
The hexadecimal string that is equivalent to the decimal value.
The original decimal value is not altered.
D2X(9) |
9 |
D2X(48) |
30 |
D2X(129) |
81 |
D2X(129, 1) |
1 /* Truncated */ |
D2X(-127,4) |
FF81 /* Sign-extended */ |
Converts a hexadecimal string to a binary string.
binary = X2B(hex)
hex is the original number in hexadecimal format.
The original number in binary format.
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 number is not altered.
X2B('CF') |
'11001111' |
X2B('41') |
'01000001' |
X2B('FF FF') |
'1111111111111111' |
Converts a hexadecimal string to an equivalent ASCII character.
ascii = X2C(hex)
hex is the original number in hexadecimal format.
The ASCII character that is equivalent to the hexadecimal value.
The original hexdecimal string is not altered.
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 */ |
Converts a hexadecimal string to a decimal string.
decimal = X2D(hex, length)
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.
The decimal string that is equivalent to the hexadecimal value.
The original hexadecimal value is not altered.
X2D('1A') |
26 |
X2D('ffff') |
65535 |
X2D('ffff', 5) |
65535 |
X2D('ffff', 4) |
-1 |
X2D('03 24') |
792 |