ultimatepp/autotest/CountBits/CountBits.cpp
İsmail Yılmaz 421eb73ac9
Bit counting functions (CountBits, CountBits64) (#232)
* Core: CountBits and CountBits64 functions are added.

* autotest: CountBits test added.

* Core: inline force on CountBits and CountBits64
2025-02-14 19:25:25 +01:00

33 lines
802 B
C++

#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_FILE|LOG_COUT);
DUMP(CountBits(0x0001));
DUMP(CountBits(0x000f));
DUMP(CountBits(0x00ff));
DUMP(CountBits(0x0fff));
DUMP(CountBits(0xffff));
DUMP(CountBits(0x000fffff));
DUMP(CountBits(0x00ffffff));
DUMP(CountBits(0x0fffffff));
DUMP(CountBits(0xffffffff));
LOG("====================");
DUMP(CountBits64(0x00000001ffffffff));
DUMP(CountBits64(0x0000000fffffffff));
DUMP(CountBits64(0x000000ffffffffff));
DUMP(CountBits64(0x00000fffffffffff));
DUMP(CountBits64(0x0000ffffffffffff));
DUMP(CountBits64(0x000fffffffffffff));
DUMP(CountBits64(0x00ffffffffffffff));
DUMP(CountBits64(0x0fffffffffffffff));
DUMP(CountBits64(0xffffffffffffffff));
CheckLogEtalon();
}