FreeMat

- Main Page
- Related Pages

NUM2HEX Convert Numbers to IEEE Hex Strings

Section: Elementary Functions

# Usage

Converts single and double precision arrays to IEEE hex strings. The syntax for its use is

       y = num2hex(x)

where `x` is either a `float` or `double` array. The output `y` is a `n-by-p` character array, where `n` is the number of elements in `x`, and `p` is 16 for `double` arrays, and 8 for `single` arrays.

# Example

Some interesting numbers

    --> num2hex([1 0 0.1 -pi inf nan])

    ans =
    3ff0000000000000
    0000000000000000
    3fb999999999999a
    c00921fb54442d18
    7ff0000000000000
    fff8000000000000

The same in single precision

    --> num2hex(float([1 0 0.1 -pi inf nan]))

    ans =
    3f800000
    00000000
    3dcccccd
    c0490fdb
    7f800000
    fff80000