Radix Conversion (MB, MO, MX)

Radix Conversion (MB, MO, MX)

Top  Previous  Next

 

The radix conversion codes convert a number to/from binary (MB), octal (MO) or hexadecimal (MX).

 

 

Input Conversion

 

The MB, MO and MX conversions take a number represented by a character string of binary, octal or hexadecimal digits and converts it to an internal integer value. The Z suffix described below for output conversion is ignored on input conversion.

 

Addition of the 0C suffix to these codes (MB0C, MO0C, MX0C) takes a character string holding a series of binary, octal or hexadecimal digits and translates each group of 8, 3 or 2 digits to the corresponding ASCII character. If the source data is not an exact multiple of 8, 3 or 2 digits in length, as appropriate to the conversion type, implied leading zeros are added.

 

The MBUC, MOUC and MXUC conversion codes are similar to MB0C, MO0C and MX0C but take a character string holding a series of binary, octal or hexadecimal digits and translates each group of 16, 6 or 4 digits to the corresponding character. If used on a non-ECS mode system, attempting to convert data that would yield characters outside the 8 bit set will fail.

 

 

Output Conversion

 

The MB, MO and MX conversions convert a number to binary, octal or hexadecimal form as a character string. Non-integer values are truncated towards zero. Negative values are treated as unsigned 32 bit values. Leading zeros are suppressed by default. If the Z suffix is added to the conversion code (e.g. MXZ) leading zeros are added to form a 32 bit value or, if the source data is over 32 bits, a 64 bit value.

 

The addition of the 0C suffix to any of these conversion codes treats the source data as a character string and converts each character to its eight digit binary, three digit octal or two digit hexadecimal representation.

 

The MBUC, MOUC and MXUC conversion codes are similar to MB0C, MO0C and MX0C but return the data for each character as a sixteen digit binary, six digit octal or four digit hexadecimal value. Although supported on all versions of QM, these are of particular use of ECS mode systems where MB0C, MO0C and MX0C will not produce the correct result for characters outside the 8 bit set.

 

 

Examples

 

Input conversion:

Source data

Conversion

Result

1110

MB

14

37777777762

MO

-14

97AB

MX

38827

010000010100001001000011

MB0C

ABC

101102103

MO0C

ABC

414243

MX0C

ABC

 

Output conversion:

Source data

Conversion

Result

19

MB

10011

19

MO

23

19

MX

13

19

MBZ

00000000000000000000000000010011

19

MOZ

00000000023

19

MXZ

00000013

ABC

MB0C

010000010100001001000011

ABC

MO0C

101102103

ABC

MX0C

414243

AB

MBUC

00000000010000010000000001000010

AB

MOUC

000101000102

AB

MXUC

00410042