3 ms·
I feel like you should be able to get away with a 2-byte constant of 0x3bec, but I haven't been able to simplify the bitshift amount enough, from (n >> 2 << 2)
by saalweachter 12y ago
I feel like you should be able to get away with a 2-byte constant of 0x3bec, but I haven't been able to simplify the bitshift amount enough, from (n >> 2 << 2) + 2 * (n % 2).
ETA:
I think the simplest I can get it is:
days(n) = 28 + (0x1df6 << (1^n&3) >> n) & 3
My intuition is that the 1^n&3 isn't going to be cheaper.