﻿# MX\_OCVT

_Reviewed and revised April 2024_

**xcall MIAMEX, MX\_OCVT, number, size, flags \{,strbuf\}**

MX\_OCVT (MIAMEX 9) outputs a number in either hex or octal format.

**Parameters**

_number_  ([Unsigned Int](integer-unsigned.md))  \[in\]

Number to display.

_size_  ([Unsigned Int](integer-unsigned.md))  \[in\]

Width (number of digits) for the formatted display. If zero, the width will be set automatically to just enough to fit. Otherwise the display is padded leading zeroes or spaces to the specified size. Maximum _size_ is 64 digits.

_flags_  ([Bitmap](bitmap.md), 8 bits)  \[in\]

Zero or more options from the following table.

| **Symbol** | **Value** | **Description** |
|------|------|------|
| OT\_ZER | \&h0001 | Leading zero blanking |
| OT\_TRM | \&h0002 | Output to terminal |
| OT\_MEM | \&h0004 | Output to memory |
| OT\_LSP | \&h0010 | Output leading space |
| OT\_TSP | \&h0020 | Output trailing space |
| OT\_OCT | \&h0040 | Force output in octal |
| OT\_HEX | \&h0080 | Force output in hex |
| **Definition file: [ashell.def](ashell.md)** | | 

[Hex-Decimal Values](hex-decimalvalues.md)



strbuf  ([String](string.md))  \[out\]

String variable to receive the formatted number if OT\_MEM flag set. Otherwise this parameter can be omitted.

**Comments**

If neither OT\_OCT nor OT\_HEX set, it will use the current default radix. See [MX\_GETHEX, MX\_SETHEX](mx_get_set_hex.md).

The confusingly named OT\_ZER bit causes leading zeroes to be converted to spaces; see _size_ and _History_. The OT\_TRM bit should always be specified, and is included for compatibility reasons. The OT\_LSP** **and OT\_TSP** **bits output an additional leading space and trailing space respectively.

The OT\_MEM** **bit indicates that the output is to be stored in memory (and not output directly to the terminal). If this bit is specified, then the fifth parameter ([String](string.md)) must be present, which is a string or unformatted variable into which the formatted numerical output is returned.

See the wrapper functions [Fn'Dec2Hex\$(decval,flags,width)](https://bitbucket.org/microsabio/soslib/src/master/907010/fndec2hex.bsi) and [Fn'Hex2Dec(hex\$)](https://bitbucket.org/microsabio/soslib/src/master/907010/fnhex2dec.bsi) in the [SOSLIB:\[907,10\]](https://bitbucket.org/microsabio/soslib/src/master/907010/).

**History**

2025 August, A-Shell 7.0.1775:  Maximum supported _size _(width) increased from 8 to 64.

2016 June, A-Shell 6.3.1516:  MX\_OCVT now supports 48 bit values, up from 32. This is equivalent to 12 hex characters or 16 octal characters. Note that the standard [Fn'Dec2Hex\$() in SOSLIB\[907,10\]](https://bitbucket.org/microsabio/soslib/src/master/907010/fndec2hex.bsi) function has been updated accordingly.