FP issues
Posted: Tue Feb 16, 2016 2:50 pm
The following code does not print correct Floating point values....
Do I have to include a special lib ??
The only inclued I'm using is 'ESP8266WiFi.h'
I could not display float values on webpage .002222 was showing .00
Serial.print should show ,x decimals
This is the output----
Do I have to include a special lib ??
The only inclued I'm using is 'ESP8266WiFi.h'
I could not display float values on webpage .002222 was showing .00
Serial.print should show ,x decimals
Code: Select all
int RFH = 8;
float Hr = 0;
float yy = 0;
float zz = 0;
void setup() {
Serial.begin(38400); // start serial for debug
delay(10);
}
void loop() {
delay(500);
Serial.print("RFH= ");
Serial.println(RFH);
delay(500);
zz = RFH/3600 ; // Arduino 5 decimals 8/3600=.00222
Serial.print("zz=RFH/3600= ");
Serial.println(zz,5);
Serial.println(zz*1000000);
delay(500);
Serial.print("Serial.print 8/3600,6= ");
Serial.println(8/3600,5);
Serial.println(8000000/3600);
delay(500);
yy = Hr + zz; // Hr = 0 @ start 0.00222
Serial.print("yy= ");
Serial.println(yy,5);
Serial.println(yy*1000000);
delay(500);
Serial.print("Hr=yy= ");
Hr = yy;
Serial.println(Hr,5);
Serial.println(Hr*1000000);
}
This is the output----
Code: Select all
PORT OPEN 38400
Serial.print 8/3600,6= 0
2222
yy= 0.00000
0.00
Hr=yy= 0.00000
0.00
RFH= 8
zz=RFH/3600= 0.00000
0.00
Serial.print 8/3600,6= 0
2222
yy= 0.00000
0.00
Hr=yy= 0.00000
0.00