I am using Silicon Labs C8051F344 controller and for one of my project the floating point precision required is 6 digits after decimal point. I am now facing with the following problem:
#include <C8051F340.H> float idata flt; void main(void) { PCA0MD &= ~0x40; // (Disable Watchdog timer) flt = 105563.578453; // Float value assignment to flt while(1); }
Above is just a sample program to test the value of float variable "flt". I have observed the value of flt as 105563.6 (got rounded off) in debug mode against the expected 105563.578453. What's the problem here ???? I have also tried some more values. flt= 216.416736;_____ Value at Debug-> 216.4167 flt= 2164.167365;____ Value at Debug-> 2164.167 flt= 2164167.365214;_ Value at Debug-> 2164167 flt= 2164.300214;____ Value at Debug-> 2164.3 Now float is supposed to have a precision of 6 digits after decimal point. But the assignment is happening strangely. I searched many of the existing threads but didn't find any convincing answer. Any guidance in the matter would be of great help. Thank you in advance. Regards, Jaydeep