diff options
Diffstat (limited to 'src/common/common/bitvalue.cpp')
-rw-r--r-- | src/common/common/bitvalue.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/common/common/bitvalue.cpp b/src/common/common/bitvalue.cpp new file mode 100644 index 0000000..16d5ef0 --- /dev/null +++ b/src/common/common/bitvalue.cpp @@ -0,0 +1,30 @@ +/*************************************************************************** + * Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "bitvalue.h" + +const uint GenericValue::INVALID = 0xFFFFFFFFU; + +BitValue BitValue::XORn(uint n) const +{ + uint nb = nbBits(_value); + uint mask = maxValue(NumberBase::Bin, n); + uint res = 0x0; + for (uint i=0; i<nb; i +=n) { + res ^= (_value >> i) & mask; + //qDebug("%i %s %s", i, toHexLabel((value>>i) & mask, 4).latin1(), toHexLabel(res, 4).latin1()); + } + return res; +} + +BitValue BitValue::XNORn(uint n) const +{ + BitValue res = XORn(n); + BitValue mask = maxValue(NumberBase::Bin, n); + return res.complementInMask(mask); +} |