added: Uint::BitNot2() this method has been proposed by

Arek <kmicicc AnTispam users.sourceforge.net>


git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@41 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2007-04-23 21:35:55 +00:00
parent bb16c871c9
commit bc9d528a75
2 changed files with 30 additions and 2 deletions

View File

@ -64,8 +64,8 @@
*/
#define TTMATH_MAJOR_VER 0
#define TTMATH_MINOR_VER 8
#define TTMATH_REVISION_VER 1
#define TTMATH_PRERELEASE_VER 0
#define TTMATH_REVISION_VER 2
#define TTMATH_PRERELEASE_VER 1
/*!

View File

@ -1529,6 +1529,34 @@ public:
}
/*!
this method performs a bitwise operation NOT but only
on the range of <0, leading_bit>
for example:
BitNot2(8) = BitNot2( 1000(bin) ) = 111(bin) = 7
*/
void BitNot2()
{
uint table_id, index;
if( FindLeadingBit(table_id, index) )
{
for(uint x=0 ; x<table_id ; ++x)
table[x] = ~table[x];
uint mask = TTMATH_UINT_MAX_VALUE;
uint shift = TTMATH_BITS_PER_UINT - index - 1;
if(shift)
mask >>= shift;
table[table_id] ^= mask;
}
else
table[0] = 1;
}
/*!