I recently had to do a codility test. The question itself was reasonably easy. take a string of numbers and +, * loop through it, if the character is a number, add it to a stack, if its an operation pop two items off the stack, perform the operation and put the result back on the stack.
The tricky small print however, specifed that the stack store values as 12 bit unsigned ints.
This gave me a lot of trouble I tried bitwise shifting back and forth but got negative numbers and eventualy I had to just do % 4096 before I ran out of time.
Also I realised that really I might have to create a special 12bit add and multiply operators, or would I be ok just converting a 16bit result?
Have I missed a trick?
What is the best way to emulate 12 bit uint math in c#?