Hi,
i am receiving a number '76264992' via rf module. i want to divide this number with 1000000 to make it '76.264992', but instead when i try the division i only get '76.26'. i want more decimals points. i want to store this value into another variable not print on screen, so how do i do it?
How do you know you only get 2 decimal places? If you output it on screen then your print function most likely formats it this way when it converts float to string, which has nothing to do with the actual precision the float is stored at.
this is the string i receive via rf. then i split them and store each substring separately. later i convert them to integers like this.
"latitude = first.toInt();
float x = latitude / 1000000;"
But x is storing only up to 2 decimal points.
i want x to store more decimal points.
To print on LCD, use this way:
format: lcd.print (variable, decimal places);
lcd.print (xxxx, 6);
The LCD shows the value in xxxxx followed by 6 decimal places.
Be warned: On an UNO/Nano/MEGA/Mini... the floating-point numbers can only hold 6 or 7 significant digits. In .print() you can display MANY decimal digits but only the first 6 digits are always correct. For example, your '76264992' has 8 digits. If you convert it to float and back to unsigned long you can expect the 8th digit, and sometimes the 7th digit, to change.