Converts an integer to a $BIT bitstring.
Examples
The following example show the conversion of the integers 1 through 9 to bitstrings:
SET x=1
WHILE x<10 {
WRITE !,x,"="
FOR i=1:1:8 {
WRITE $BIT($FACTOR(x),i) }
SET x=x+1 }
The following example show $FACTOR conversion of negative numbers and fractions to positive integers:
FOR i=1:1:8 {WRITE $BIT($FACTOR(17),i)}
WRITE " Positive integer",!
FOR i=1:1:8 {WRITE $BIT($FACTOR(-17),i)}
WRITE " Negative integer (absolute value)",!
FOR i=1:1:8 {WRITE $BIT($FACTOR(16.5),i)}
WRITE " Positive fraction (rounded up)",!
FOR i=1:1:8 {WRITE $BIT($FACTOR(-16.5),i)}
WRITE " Negative fraction (rounded up)"
The following example show the bitstring returned when the scale argument is specified:
SET x=2.7
WRITE !,x," scaled then rounded to an integer:",!!
FOR i=1:1:12 {
WRITE $BIT($FACTOR(x),i) }
WRITE " binary = ",$NORMALIZE(x,0)," decimal",!
SET scale=1
SET y=x*(10**scale)
FOR i=1:1:12 {
WRITE $BIT($FACTOR(x,scale),i) }
WRITE " binary = ",$NORMALIZE(y,0)," decimal",!
SET scale=2
SET y=x*(10**scale)
FOR i=1:1:12 {
WRITE $BIT($FACTOR(x,scale),i) }
WRITE " binary = ",$NORMALIZE(y,0)," decimal"