Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.1 - English

Change language to:
Français - 日本語 - Português

Please note that the recommended version of Scilab is 2023.1.0. This page might be outdated.
See the recommended documentation of this function

Scilab help >> Elementary Functions > Integer representation > dec2bin


binary representation

Calling Sequence




scalar/vector/matrix of positives integers


a positive integer


a string or a vector of string


Given x, a positive (or a vector/matix of integers) integer, this function returns a string (or a column vector of strings) which is the binary representation of x.If dimension of x is superior than 1 then each component of the colums vector str is the binary representation of the x components (i.e str(i) is the binary representation of x(i)). If the components length of str is less than n ( i.e length str(i) < n ), then add to str components the characters '0' on the left in order to have componants length equal to n.


// example 1 :

// example 2 :
// the binary representation of 86 is: '1010110'
// its length is 7(less than n), so we add to str, 8 times the character '0'  (on the left)

// example 3 :

See Also

  • base2dec — conversion from base b representation to integers
  • bin2dec — integer corresponding to a binary form
  • oct2dec — conversion from octal representation to integers
  • hex2dec — conversion from hexadecimal representation to integers
  • dec2oct — octal representation of integers
  • dec2hex — hexadecimal representation of integers
<< bin2dec Integer representation dec2hex >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Mar 03 10:59:35 CET 2011