This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

bin2dec

Convert text representation of binary number to decimal number

Syntax

bin2dec(binarystr)

Description

bin2dec(binarystr) interprets binarystr, text that represents a binary number, and returns the equivalent decimal number. binarystr must represent a nonnegative integer value smaller than or equal to the value returned by flintmax.

binarystr can be a character array, a cell array of character vectors, or a string array. bin2dec ignores any space characters in the input text.

Examples

Binary 010111 converts to decimal 23:

bin2dec('010111')
ans =
    23

Because space characters are ignored, this string yields the same result:

bin2dec(' 010   111 ')
ans =
    23

Extended Capabilities