From ac7e6ff2330d7e907f4b8c4417c79400887034b2 Mon Sep 17 00:00:00 2001 From: Jonny007-MKD <1-23-4-5@web.de> Date: Mon, 6 Jan 2014 20:31:23 +0100 Subject: [PATCH] Fixed Gray calculation in KV_PiEleLoc --- Hazard/Hazard/KV_PiEleLoc.h | 5 +++-- Hazard/Hazard/PrimImplikant.cpp | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Hazard/Hazard/KV_PiEleLoc.h b/Hazard/Hazard/KV_PiEleLoc.h index ebcc26d..e0393e6 100644 --- a/Hazard/Hazard/KV_PiEleLoc.h +++ b/Hazard/Hazard/KV_PiEleLoc.h @@ -1,6 +1,7 @@ #pragma once #include "stdafx.h" +#include "Tools.h" using namespace std; @@ -20,9 +21,9 @@ public: this->i = i; this->w = i & ((0x1 << (numVarX)) - 1); // get x coord - this->w ^= w/2; // make it gray + this->w = Tools::GrayToBinary(w); this->h = i >> numVarX; // get y coord - this->h ^= h/2; // make it gray + this->h = Tools::GrayToBinary(h); } }; diff --git a/Hazard/Hazard/PrimImplikant.cpp b/Hazard/Hazard/PrimImplikant.cpp index 62933eb..d15b482 100644 --- a/Hazard/Hazard/PrimImplikant.cpp +++ b/Hazard/Hazard/PrimImplikant.cpp @@ -2,6 +2,7 @@ #include #include #include +#include "Tools.h" #include "PrimImplikant.h" using namespace std; @@ -53,11 +54,7 @@ void PrimImplikant::sort() bool PrimImplikant::compareGray(uint a, uint b) { - for (uint i = 1; i < dimension; i++) - a ^= a / 2; // convert a from gray to binary - for (uint i = 1; i < dimension; i++) - b ^= b / 2; // convert b from gray to binary - return a < b; + return Tools::GrayToBinary(a) < Tools::GrayToBinary(b); } void PrimImplikant::makeLocations()