How would I print a mathematical result that has decimal places?
I tried to use all variable types
float variable;
variable = 732/1024*5;
Serial.print(variable);
This prints out "3.00"
732/1024*5 is equal to 3.57
How would I print a mathematical result that has decimal places?
I tried to use all variable types
float variable;
variable = 732/1024*5;
Serial.print(variable);
This prints out "3.00"
732/1024*5 is equal to 3.57
variable = 732.0/1024.0*5.0;
I tried to use all variable types
Except the really obvious one.
Thanks bro +1 karma
I'm surprised it didn't print 0.00 since 732/1024 is zero in integer math and 0 * 5 is zero. Don't * and / work left to right?
I'm surprised it didn't print 0.00
The posted code does print out 0.00.
Unsurprisingly, firehoax did not show us the real code, ha ha.