long a=99999999;
long b=100;
float c=a*b;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(c);
}
void loop() {
// put your main code here, to run repeatedly:
}
I even tested two Arduino board models, one UNO and the other Pro Micro, but the answers were wrong.
What exactly should I do?
99999999 is a 27 bit binary number.
Multiply that by 100, and it becomes a 33 bit number.
Now imagine representing that number accurately in 32 bits.
(This isn't a troubleshooting or installation issue)
Then your print will probably give you "ovf"
(but the value will be usable in subsequent calculations. With some loss of precision.)
For example:
long a=888888888;
long b=100;
float c=(float)a*b;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(c/10000.);
}