MOD is the
modulo operation: MOD(a,b) is from 0 to b-1 (a and b both int32_t, b > 1). C has the % operator, but that one gives negative numbers as well, which doesn't match what I've learned in the math class about modulo (see
https://en.wikipedia.org/wiki/Modular_arithmetic ). That's why I've defined the MOD macro in imath.h.
And 150 * 40 / 100 = 60.
However, that definition wraps around at 102 degrees to 0, so it will fail at negative temperatures. A better version that works from -20 to 80 degrees is:
#define EFIC_CELSIUS (MOD(efic_temp - 100, 256) * 40 / 100 - 20)
Before/after (efic_temp from 0 to 255):
42 42 43 43 44 ... 101 101 102 0 0 0 1 1 2 ... 40 40 41 41 42
42 42 43 43 44 ... 81 81 82 -20 -20 -20 -19 -19 ... 40 40 41 41 42
I'm not sure at which point this number really wraps around, but at least this definition should cover the usual temperature range. If anyone wants to place his EOS M in a freezer or oven for measurements, that data would be welcome, but please be very careful with condensation and/or heat (you can damage the camera). Or, it may be safer to just find the conversion function in Canon code.