Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Gray-code/BBC-BASIC/gray-code.basic
Normal file
15
Task/Gray-code/BBC-BASIC/gray-code.basic
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
INSTALL @lib$+"STRINGLIB"
|
||||
|
||||
PRINT " Decimal Binary Gray Decoded"
|
||||
FOR number% = 0 TO 31
|
||||
gray% = FNgrayencode(number%)
|
||||
PRINT number% " " FN_tobase(number%, 2, 5) ;
|
||||
PRINT " " FN_tobase(gray%, 2, 5) FNgraydecode(gray%)
|
||||
NEXT
|
||||
END
|
||||
|
||||
DEF FNgrayencode(B%) = B% EOR (B% >>> 1)
|
||||
|
||||
DEF FNgraydecode(G%) : LOCAL B%
|
||||
REPEAT B% EOR= G% : G% = G% >>> 1 : UNTIL G% = 0
|
||||
= B%
|
||||
Loading…
Add table
Add a link
Reference in a new issue