Java function equivalent to c ++ map ()

2

There is a function for java, equivalent to map () of c ++?

Basically it calculates the ratio between the "minimum" and "maximum" values.

    
asked by anonymous 28.05.2016 / 04:33

1 answer

3

Apparently, there is no such standard function in Java, probably in C ++, but only in Arduino for the conversion of sensor values.

You can implement it in your project because it is very simple, and the code is in the link you posted:

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
    
28.05.2016 / 05:01