The map function should produce a float (see code below). If one looks at the first 10 results, with i first and then i mapped between 85.0 and 170.0, we have:
85 85.0
86 87.0
87 89.0
88 91.0
89 93.0
90 95.0
91 97.0
92 99.0
93 101.0
94 103.0
BUT by my calculations, we should have:
85 85.0000
86 87.0060
87 88.9950
88 91.0010
89 93.0070
90 94.9960
91 97.0020
92 99.0080
93 100.9970
94 103.0030
How do I get the more accurate result? I have tried workarounds such as converting to string and then converting back to float.
float threshold1 = 85.0;
float threshold2 = 170.0; // threshold2 > threshold1
void setup() {
}
void draw() {
for (int i = 85; i < 170; i++ ) {
float m = map(i, threshold1, threshold2, threshold1, 255.0);
//
println(i, m); // error checking
}
exit();
}