Decimal To Binary

Routine Summary

Converts a decimal (base 10) number to a binary (base 2) number.


A - The decimal number that you want to convert.


L₁ - The binary representation of the decimal number, expressed as a list.

Variables Used

A, B, L₁

Calculator Compatibility






This routine takes a positive whole decimal number (base 10), stored in A, and converts it to the equivalent binary (base 10) representation. The binary representation will be in list form. For example, the decimal number 32 is the binary number 100000, meaning the routine would result in the list {1,0,0,0,0,0}. To learn how to convert a decimal number to a binary number, vice versa, and even see how to convert to and from other bases besides decimal and binary, see the Binary and Hexadecimal page.

It also may be important to note that adding 0’s to the front of a binary number will not change the decimal equivalent. For example, both 01101012 and 1101012 are equivalent to 5310.

Error Conditions

  • ERR:DATATYPE is thrown if A is imaginary.
  • ERR:NONREALANS is thrown if A is negative.
  • ERR:DOMAIN is thrown if A is 0.
  • An error will not be thrown is A isn’t an integer. Nonetheless, the conversion will not work correctly.

Related Routines


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.