**BIN$**

*function: convert a decimal value into a string of binary digits*

b$=**Bin$**(value)

b$=**Bin$**(value,digits)

This is the function that converts a decimal number or expression into the equivalent string of binary digits. The binary number that is returned will automatically have a leading % (per cent) character added to it. This character acts as an introduction sign, to indicate that the number which follows it is in binary notation, rather than the standard decimal system.

After the decimal value that is to be converted, an optional number between 1 and 31 can be added which sets the number of digits to be returned in the binary string. If this parameter is omitted, AMOS Professional will express the value in the fewest possible digits, with no leading zeros. Here are a few examples:

E> Print Bin$(5) Print Bin$(10) Print Bin$(255) X$=Bin$(100) : Print X$

You may enter binary numbers directly, as part of an expression, providing that the % (per cent) character is placed in front of your binary value. Such numbers will be converted into standard decimal notation automatically. For example:

E> Print %101 Print %1010 Print %11111111 X$=Bin$(100) : Print Val(X$)

Certain functions make use of yet another system of counting. The Hexadecimal system counts in units of 16 rather than ten, so a total of 16 different digits is needed to represent all the different numbers. The digits from 0 to 9 are used as normal, but the digits from 10 to 15 are signified by the letters A to F, as shown in the following table:

Hex digit0 1 2 3 4 5 6 7 8 9 A B C D E FDecimal0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

**HEX$**

*function: convert a decimal value into a string of hexadecimal digits*

h$=**Hex$**(value)

h$=**Hex$**(value,digits)

HEX$ converts numbers from the decimal system into a string of hexadecimal (Hex) digits. The decimal value to be converted is specified in brackets. The hex number that is returned will automatically have a leading $ (dollar) character added to it.