BIN( ) |
Binary String from Numeric Value |
BIN(num,len[,ERR=stmtref])
Where:
len |
Length of the string to be returned. Use a numeric expression. Integer value. |
num |
Numeric value to convert to a string. Use a numeric expression. Integer value. |
stmtref |
Program line number or statement label to which to transfer control. |
Binary value of ASCII string corresponding to the numeric expression.
The BIN( ) function converts the numeric expression num to an ASCII string (as its binary value). The string returned will be the length specified, len. The value is right justified in the resultant string.
The value is converted to two's complement format before the string is generated. If the number was negative, the leading bits will all be set to ON (binary 1).
2 |
is binary 00000010 |
1 |
is binary 00000001 |
0 |
is binary 00000000 |
-1 |
is binary 11111111 |
-2 |
is binary 11111110 |
B$=bin(40,1);
print hta(B$) ! yields $28$ 00101000
B$=bin(40,2);
print hta(B$) ! yields $0028$ 00000000 00101000
B$=bin(2048,2);
print hta(B$) ! yields $0800$ 00001000 00000000
B$=bin(-64,2);
print hta(B$) ! yields $FFC0$ 11111111 11100000