AnsweredAssumed Answered

A bug in the Sample

Question asked by viscocoa on Feb 27, 2012
Latest reply on Feb 28, 2012 by mobileappsgallery

In the file SDKCommon.cpp

 

template<typename T>
T SDKCommon::roundToPowerOf2(T val)
{
    int bytes = sizeof(T);

    val--;
    for(int i = 0; i < bytes; i++)
        val |= val >> (1<<i); 
    val++;

    return val;
}

 

This is wrong. The times of loop should be 3 for 8 bit number, 4 for 16 bit number, 5 for 32 bit number, ...

Outcomes