Table of Contents

ugBASIC User Manual

BIN

SYNTAX

   = BIN( value [, digits] )

PURPOSE

The BIN command allows you to convert a decimal number into a binary representation. In other words, it takes a number that we are used to writing in base 10 (with the digits 0 through 9) and turns it into a sequence of 0s and 1s, which is the base that computers use to represent data internally. It decode from the most significant to the least significant.

It is also possible to indicate the number of digits to be represented. If this parameter is omitted, the minimum number of digits for that data format (8, 16 or 32 digits) will be used.

This command is essential for those who want to delve deeper into how computers work at a lower level. Infact, this command allows you to operate directly on individual bits of a number, which is useful in some applications such as graphics or communications. Moreover, many encryption algorithms rely on bit-level operations.

EXAMPLE

  x = BIN(42)
  z = BIN(42, 5)

ABBREVIATION

 Bi

AVAILABLE ON

ANY PROBLEM?

If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please open an issue for this keyword on GitHub. Thank you!

POWERED BY