Skip to content

bin2dec

Convert a binary string to a decimal number.

v = bin2dec(b)

Parses b (a string of 0s and 1s, up to 10 bits) as a binary number and returns its decimal value. Two’s-complement negative encoding when the leading bit is set.

bin2dec('1100100') % 100
bin2dec('1111111111') % -1 (two's complement)
  • bin2hex — Convert a binary string to a hexadecimal string.
  • bin2oct — Convert a binary string to an octal string.
  • decimal — Convert a numeric string in any radix to a decimal number.
  • base — Convert an integer to a string in a specified radix.