Description
Converts from internal storage format to hex, octal, and binary formats.
Syntax
output = OConv (expression, "MX")
output = OConv (expression, "HEX")
output = OConv (expression, "MO")
output = OConv (expression, "'MB")
Parameters
OConv (DT) accepts the following arguments for its parameters.
Parameters | Description |
---|---|
expression | Yields a decimal value. Scientific notation is accepted. |
MX | The expression must be a decimal number (base 10) and is converted to the equivalent hexadecimal character set (base 16). |
HEX | The expression must be a string of ASCII characters with a maximum length of 32,766 and is converted into a string of hexadecimal character sets. |
MO | The expression must be a decimal number and is converted to an ASCII representation of an octal (base 8) number. |
MB | The expression must be a decimal number and is converted to an ASCII representation of a binary (base 2) number. If expression yields an incorrect value a 0 (zero) will be returned. |
An understanding of different number bases is helpful for the effective use of these specifications. Use the following table as a guide to conversions to different number bases.
Conversion Code | Iconv | OConv |
---|---|---|
MX | hexadecimal to decimal | decimal to hex |
MO | octal to decimal | decimal to octal |
MB | binary to decimal | decimal to binary |
Example
* Converting to hex, octal, and binary output. * The value 13 is assigned to the variable identifier C. A = 19 B = "MX" C = OConv(A, B) * The value 41 is assigned to the variable identifier C. A = "A" B = "HEX" C = OConv(A, B) /* The value 1100100 will be assigned to the variable identifier C. */ A = 1E2 B = "MB" C = OConv(A, B)