Product Site

5.1.7.27. b2x

Returns a string, in character format, that represents the receiving binary string converted to hexadecimal.

The receiving string is a string of binary (0 or 1) digits. It can be of any length. It can optionally include whitespace characters (at 4-digit boundaries only, not leading or trailing). These are to improve readability and are ignored.

The returned string uses uppercase alphabetic characters for the values A-F and does not include whitespace.

If the receiving binary string is a null string, b2x returns a null string. If the number of binary digits in the receiving string is not a multiple of four, up to three 0 digits are added on the left before the conversion to make a total that is a multiple of four.
Example 5.64. String class — b2x method
Say "11000011"~b2x     -->   "C3"
Say "10111"~b2x        -->   "17"
Say "101"~b2x          -->   "5"
Say "1 1111 0000"~b2x  -->   "1F0"

You can combine b2x with the methods x2d and x2c to convert a binary number into other forms.
Example 5.65. String class — b2x method with x2d
"10111"~b2x~x2d  -->   "23"   /* decimal 23 */