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.

hex2dec

Convert text representation of hexadecimal number to decimal number

Syntax

d = hex2dec('hex_value')

Description

d = hex2dec('hex_value') converts hex_value to its floating-point integer representation. The argument hex_value is a hexadecimal integer stored as text. If the value of hex_value is greater than the hexadecimal equivalent of the value returned by flintmax, then hex2dec might not return an exact conversion.

The input argument hex_value can be a character array, cell array of character vectors, or string array.

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

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

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

Examples

hex2dec('3ff')

ans =

        1023

For a character array S,

S =
0FF
2DE
123
hex2dec(S)

ans =

255
734
291
Was this topic helpful?