The first time, pow() works. But inside of a 'for loop', or again afterwards, it doesn't behave !? (I'm using a Chinese Pro Mini with Arduino 1.8.16)
EDIT To clarify what I am asking, my question is: "Why does pow() only give the correct answer the first time?"
uint8_t places;
uint8_t temp8;
uint32_t n;
void setup() {
Serial.begin(115200);
}
void loop() {
places = 5U;
n = pow( 10, places);
Serial.println(n);
Serial.println("\nHERE'S THE SAME CODE INSIDE OF A 'FOR LOOP'\n");
for (temp8 = 0; temp8 < places; temp8++) {
n = pow( 10, places);
Serial.println(n);
}
Serial.println("\nNOW THE EXACT SAME CODE AS BEFORE GIVES A DIFFERENT RESULT\n");
n = pow( 10, places);
Serial.println(n);
while(1){}
}
Here's what the serial monitor shows:
100000
HERE'S THE SAME CODE INSIDE OF A 'FOR LOOP'
99999
99999
99999
99999
99999
NOW THE EXACT SAME CODE AS BEFORE GIVES A DIFFERENT RESULT
99999