mode
If mode is 0, the algorithm returns the bit on position ‘bitpos’. If mode is 1 (default), the algorithm returns the most significant bit,
if mode is 2 it returns the second significant bit and if mode is 3 the return value is the integer value of the last four bits