I can see that we are going to have to do some brain gymnastics with our formulas to make them stay out of floating point land and then just cut them down to size when it is time to do something with them!!
Another example or two would really help to get my brain into gear.
And I realised that I have a need to calculate lux from the output of a TSL2561 sensor.
There are several formula in the datasheet dependant on the ratio of CH1/CH2 (both 16 bit values) like this:
Lux = 0.0304*CH0 − 0.062*CH0*((CH1/CH0)1.4) -- (that is raise to the power of 1.4)
or
Lux = 0.0128*CH0 − 0.0153*CH1
Now the datasheet (and the every-bountiful adafruit example library for arduino) embody a method of doing this without floating point, but I can't quite follow all the twists and turns, and anyway, I'm sure there are more elegant ways of doing this in lua. My attempt at the simpler formula is this:
Lux=(128 * CH0 - 153 * CH1 ) / 10000
Am I on the right lines - and how would one be able to do the more complex one? datasheet is here
http://www.datasheetlib.com/datasheet/867868/tsl2561_pacer-international.html?page=22#datasheet (html doesn't show calculations properly
- pdf does -
http://www.adafruit.com/datasheets/TSL2561.pdfI don't know enough maths to begin to even think about how to do powers