Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

hex2num

Convert IEEE hexadecimal string to double-precision number

Syntax

n = hex2num(S)

Description

n = hex2num(S), where S contains 16 characters representing a hexadecimal number, returns the IEEE® double-precision floating-point number n that it represents. Fewer than 16 characters are padded on the right with zeros. S can be a character array, a cell array of character vectors, or a string array.

  • If S is a character array, each row is interpreted as a double-precision number, and n is returned as a column vector.

  • If S is a cell array of character vectors, each element is interpreted as a double-precision number, and n is returned as a column vector.

  • If S is a string array, each element is interpreted as a double-precision number, and n is returned as a numeric array with the same size as S.

NaNs, infinities and denorms are handled correctly.

Examples

hex2num('400921fb54442d18')

returns Pi.

hex2num('bff') 

returns

ans =

    -1

Introduced before R2006a

Was this topic helpful?