| |
|
|
p.specht
| Graycode helps sometimes, Vereinfachungsmöglichkeiten with elekronischen Steuerschaltungen To discern, there itself of step To step each only 1 bit changes. Dummerweise there but immediately several Graycodes, where some z.B. on Drehgebern inserted go (one can The Lichtschranken-Schaltkulisse then in a only, coherent Piece produce).
Window Title "Bin2Gray and Gray2Bin"
' Binärcode to Graycode and zurückwandeln
' (CL) Copyleft 2013-06 by P. woodpecker
' Q: https://de.wikipedia.org/wiki/Gray-code
cls:font 2:Windowstyle 1048
var v$=mkstr$("0",32):declare gray&
whileloop 0,20000000
locate 10,23:print right$(v$+be$(&Loop),32)
gray&=be2gray(&Loop)
locate 14,23:print right$(v$+be$(gray&),32)
locate 18,23:print right$(v$+be$(gray2be(gray&)),32)
waitinput 400
endwhile
waitinput
end
proc be2Gray
parameters bin&
return xor(bin&,bin&\2)
endproc
proc Gray2be
parameters Gray&
declare i&,k&
whileloop 31,0,-1:i&=&Loop
k&=k& | XOR((((1 <<(&Loop+1)) & k&)>>1),(1<<&Loop) & Gray&)
endwhile
return k&'binary
endproc
|
|
|
| Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 05/09/21 ▲ |
|
|
|