I am making a simple división.... and I always get 0.00;
Where is the problem ??????
float j;
j = 5 / 100;
Serial.println("Valor regulado");
Serial.println(j);
Hi again, I answer myself. I have to use float numbers....
j = 5.00 / 100.00
I am making a simple división.... and I always get 0.00;
Where is the problem ??????
float j;
j = 5 / 100;
Serial.println("Valor regulado");
Serial.println(j);
Hi again, I answer myself. I have to use float numbers....
j = 5.00 / 100.00
Yep, or at least the 5 need to be 5.0. But be aware that floats are pretty awful on an Arduino (slow and probably unnecessary.)
or use the f suffix.
j = 5f / 100f
float j;
j = 5 / 100;
Why use two lines of code when one will suffice?
float j = 5.0 / 100.0;
septillion:
Yep, or at least the 5 need to be 5.0. But be aware that floats are pretty awful on an Arduino (slow and probably unnecessary.)
Floats are indeed slow as they are calculated in software, not hardware, but that doesn't mean they
are unnecessary, all sorts of applications rely on them.
But this particular one will be done at compile-time.
Why not
float j = .05;
?