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.

dec2bin

Convert decimal number to character vector representing binary number

Syntax

str = dec2bin(d)
str = dec2bin(d,n)

Description

str = dec2bin(d) returns the binary representation of d as a character vector. d must be a nonnegative integer. If d is greater than the value returned by flintmax, then dec2bin might not return an exact representation of d.

str = dec2bin(d,n) produces a binary representation with at least n bits.

The output of dec2bin is independent of the endian settings of the computer you are using.

Examples

Decimal 23 converts to binary 010111:

dec2bin(23)
ans =
    10111
Was this topic helpful?