Hello,

I want to implement the Bilinear interpolation in arduino and accuracy is very important. http://en.wikipedia.org/wiki/Bilinear_interpolation Is there a to keep precision while doing the calculations in integers?

Thanks

Hello,

I want to implement the Bilinear interpolation in arduino and accuracy is very important. http://en.wikipedia.org/wiki/Bilinear_interpolation Is there a to keep precision while doing the calculations in integers?

Thanks

Is there a to keep precision while doing the calculations in integers?

There is a whole branch in computer science - numerical methods - trying to keep precision in computer math including integers, floats, doubles, complex etc.

using bigNumber is a very good solution although it has some performance consequences.

if you want to keep the math in integer domain, you can multiply all numbers by X and later divide the result by X. This is sort of doing math with an extra decimal. This works unless the multiplication causes overflow. If you take a power of 2 (e.g. 32) the performance penalty is quite low. (do not forget proper rounding in the end)

Can you tell us what the table looks like? Ranges X and Y axis? nr of cells? is it filled with integers? how far are they apart? (is integer interpolation possible) do you want the result to be an integer or a float?