WiringProject / Wiring

Wiring Framework
http://wiring.org.co/
Other
217 stars 168 forks source link

Wiring map function with wrong types #34

Closed dbarragan closed 10 years ago

dbarragan commented 10 years ago

when the code was re-roganized an error was introduced:

int32_t map(int32_t x, int32_t in_min, int32_t in_max, int32_t out_min, int32_t out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }

making the function to stop working with floats, it should be like this:

float map(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; }

long doesn't work as well.