English
Source / code snippets

Binärcode in a Graycode and back wandeln

 

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  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

552 Views

Untitledvor 0 min.
H.Brill09/26/24
Ernst07/21/21
Uwe ''Pascal'' Niemeier06/13/21
R.Schneider05/28/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie