From 5b739eda9699cad7aa19950b1701b19333c07cbf Mon Sep 17 00:00:00 2001 From: Jethro Stapelbroek Date: Sun, 2 Jul 2023 23:08:46 +0200 Subject: [PATCH] Logic Functions --- logicfunctions.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 logicfunctions.cpp diff --git a/logicfunctions.cpp b/logicfunctions.cpp new file mode 100644 index 0000000..ee89096 --- /dev/null +++ b/logicfunctions.cpp @@ -0,0 +1,20 @@ +#include "logicfunctions.h" + +// Compute xor +void exclusive(bool x, bool y, bool& ans){ + ans = x ^ y; +} + +// Compute implication +void implies(bool x, bool y, bool& ans){ + if (!(x || y)) { + ans = true; + } else { + ans = y; + } +} + +// Compute equivalence +void equivalence(bool x, bool y, bool& ans){ + ans = x == y; +} \ No newline at end of file