Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the 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 or a cell array of character vectors. 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
Was this topic helpful?