Question

How do I convert the following macro into a function?

#define xtime(x)   ((x<<1) ^ (((x>>7) & 1) * 0x1b))
Was it helpful?

Solution

template<typename T>
T xtime(T x)
{
    return ((x<<1) ^ (((x>>7) & 1) * 0x1b));
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top