Eigene XOR Funktion

Liebe Leser,

ein kleines Code-Snippet für alle, die die XOR-Funktion verstehen wollen ;)

#cs
Coding by www.agrafix.net
 
---------------------
The functions
---------------------
#ce
; Nand Function
Func nand($a, $b)
	Return BitNOT(BitAnd($a, $b))
EndFunc
 
; XOR Function
Func xor($a, $b)
	Return  nand(nand($a, nand($a, $b)), nand($b, nand($a,$b)))
EndFunc
 
#cs
---------------------
Proof of Concept: my xor function returns the same stuff as the Built-in XOR function
---------------------
#ce
If xor(0xAB, 0xBC) == BitXor(0xAB, 0xBC) Then ; horray, it works!
	ConsoleWrite("Congratz Bro, you coded a XOR function :D" & @CRLF)
Else ; this will never happen
	ConsoleWrite("Sorry, but you suck!" & @CRLF)
EndIf

Viel Vergnügen damit,
Agrafix

Ähnliche Beiträge:

  1. Zwei einfache Algorithmen: kgV und ggT
  2. in_array() für Javascript

Diesen Post teilen:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

Keine Kommentare zu “Eigene XOR Funktion”

Diesen Beitrag kommentieren:

Name (erforderlich):
EMail (wird nicht veröffentlicht) (erforderlich):
Webseite:
Kommentar (erforderlich):
XHTML: Du kannst diese Tags verwenden: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">