# num2hex

Convert number to hexadecimal equivalent using `quantizer` object

## Syntax

```y = num2hex(q,x) ```

## Description

`y = num2hex(q,x)` converts numeric array `x` into hexadecimal returned in `y`. When `x` is a cell array, each numeric element of `x` is converted to hexadecimal. If `x` is a structure, each numeric field of `x` is converted to hexadecimal.

For fixed-point `quantizer` objects, the representation is two's complement. For floating-point `quantizer` objects, the representation is IEEE® Standard 754 style.

For example, for `q` = `quantizer('double')`

```num2hex(q,nan) ans = fff8000000000000 ```

The leading fraction bit is 1, all other fraction bits are 0. Sign bit is 1, exponent bits are all 1.

```num2hex(q,inf) ans = 7ff0000000000000 ```

Sign bit is 0, exponent bits are all 1, all fraction bits are 0.

```num2hex(q,-inf) ans = fff0000000000000 ```

Sign bit is 1, exponent bits are all 1, all fraction bits are 0.

`num2hex` and `hex2num` are inverses of each other, except that `num2hex` returns the hexadecimal values in a column.

## Examples

This is a floating-point example using a `quantizer` object `q` that has 6-bit word length and 3-bit exponent length.

```x = magic(3); q = quantizer('float',[6 3]); y = num2hex(q,x) y = 18 12 14 0c 15 18 16 17 10 ```