MCPcopy Create free account
hub / github.com/diasurgical/devilution / GetNearestPowerOfTwo

Function GetNearestPowerOfTwo

3rdParty/StormLib/src/SBaseCommon.cpp:314–325  ·  view source on GitHub ↗

Returns the nearest higher power of two. If the value is already a power of two, returns the same value

Source from the content-addressed store, hash-verified

312// Returns the nearest higher power of two.
313// If the value is already a power of two, returns the same value
314DWORD GetNearestPowerOfTwo(DWORD dwFileCount)
315{
316 dwFileCount --;
317
318 dwFileCount |= dwFileCount >> 1;
319 dwFileCount |= dwFileCount >> 2;
320 dwFileCount |= dwFileCount >> 4;
321 dwFileCount |= dwFileCount >> 8;
322 dwFileCount |= dwFileCount >> 16;
323
324 return dwFileCount + 1;
325}
326/*
327DWORD GetNearestPowerOfTwo(DWORD dwFileCount)
328{

Callers 2

DefragmentHashTableFunction · 0.85
LoadMpkHashTableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected