# MX\_GTOCT
> [HTML Version](mx_gtoct.htm)
_Updated December 2017_
**xcall MIAMEX, MX\_GTOCT, hexoct, dec**
MX\_GTOCT (MIAMEX 160) converts hex or octal to decimal.
_hexoct_ ([String](string.htm.md)) \[in\]
Hex or octal value to convert. Radix must match the current hex/octal mode setting; see [MX\_GETHEX, MX\_SETHEX](mx_get_set_hex.htm.md). 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](num.htm.md)) \[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\]](https://bitbucket.org/microsabio/soslib/src/master/907010/). 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**
• [MX\_OCVT](mx_ocvt.htm.md)