I have, what I thought was a pretty straightforward multiplication operation, but....
uint32_t p =0;
void setup(){
Serial.begin(9600);
p = 15*60*1000;
Serial.print("Trial 1: "); Serial.println(p);
p = 15*60;
p = p*1000;
Serial.print("Trial 2: "); Serial.println(p);
p = 15*60;
p *= 1000;
Serial.print("Trial 3: "); Serial.println(p);
}
void loop(){
}
Yields:
Trial 1: 4294949792
Trial 2: 900000
Trial 3: 900000
What the f@!#^*?
I can't figure out why Trial 1 give such a wacky number. I thought it was wrap around or maybe the way print works, but as you can see the other trials work just fine. So what is going on? And here I thought I understood this stuff...
-- Thanks!