Please enable JavaScript to view this site.

A-Shell Consolidated Reference

Updated December 2017

xcall MIAMEX, MX_GTOCT, hexoct, dec

MX_GTOCT (MIAMEX 160) converts hex or octal to decimal.

hexoct  (String)  [in]

Hex or octal value to convert. Radix must match the current hex/octal mode setting; see MX_GETHEX, MX_SETHEX. In hex mode is set, the hexoct string may optionally contain prefix of "0x", "0X", or "&h". The first two are widely used hex prefixes, while the latter is the hex prefix used in ASB.

dec  (Num)  [out]

Returns the result of the conversion of hexoct to decimal. See comments.

Comments

Warning: If hexoct string does not start with a valid hex value, or if it is null, the error return value is -1. If the dec parameter is passed as an unsigned variable type (e.g. B), -1 value will appear as a positive number (e.g. 255 for B,1; 65535 for B2; etc.). While -1 is used for errors, it is also the expected (non-error) result for hexoct = "&hFFFFFFFF". If the hexoct string starts with valid hex characters, the first invalid hex character will be treated as the terminator. So "&h10A" and "&h10AZ" will both be interpreted as 266—the Z marking the effective end of the second string).

Hex/octal conversions to/from decimal are normally performed using the wrapper functions Fn'Dec2Hex$() and Fn'Hex2Dec() in the SOSLIB:[907,10]. The Fn'Hex2Dec() function implementation may contain additional logic to treat Fn'Hex2Dec("") as 0, which probably seems more natural since val("") also equals 0. Consult the function source for details.

See Also