BIN$ converts an integer to a binary string.
Syntax:RetStr = BIN$(Number AS INTEGER) Return Value:
Parameters:
|
DIM RetStr$ RetStr$ = BIN$(12345) PRINT RetStr$
11000000111001
In BCX, a literal binary numeric value can be assigned to a variable.
$BCXVERSION "7.4.7 (2020/06/29)" DIM Number Number = 0b00000001001101000011110010110100 PRINT Number
20200628
SET BinCode[] AS INTEGER 0b0000, 0b0001, 0b0010, 0b0011, 0b0100, 0b0101, 0b0110, 0b0111, 0b1000, 0b1001, 0b1010, 0b1011, 0b1100, 0b1101, 0b1110, 0b1111 END SET PRINT "Binary ", "Gray Code" FOR INTEGER i = 0 TO 15 PRINT " ", LPAD$(BIN$(BinCode[i]), 4, ASC("0")), " "; PRINT LPAD$(BIN$((BinCode[i] XOR (BinCode[i] >> 1))), 4, ASC("0")) NEXT i
Binary Gray Code 0000 0000 0001 0001 0010 0011 0011 0010 0100 0110 0101 0111 0110 0101 0111 0100 1000 1100 1001 1101 1010 1111 1011 1110 1100 1010 1101 1011 1110 1001 1111 1000