Write float value in eeprom
Posted: Thu Feb 07, 2019 5:08 pm
Hello Benj,All,
I would like, for reasons of precision, to be able to memorize in the EEPROM for example a value U = 4.9542
I tried by creating a 16-bit shift variable, with a variable U as Integer
MSB = U >> 8
LSB = U
=> EEVAL = (MSB << + LSB
eeprom1::write(0,MSB)
eeprom1::write(1,LSB)
It works but on 10bit only and the accuracy is not enough.
I can not either multiply 4.9542 * 10000 and recreate the shift variable, because the variable is type of Float and I would not get as a result 4.9542 * 10000 = 40000 (if I'm not mistaken).
Please, how can I do? Do you have an example ?
Thank you in advance for your replies
I would like, for reasons of precision, to be able to memorize in the EEPROM for example a value U = 4.9542
I tried by creating a 16-bit shift variable, with a variable U as Integer
MSB = U >> 8
LSB = U
=> EEVAL = (MSB << + LSB
eeprom1::write(0,MSB)
eeprom1::write(1,LSB)
It works but on 10bit only and the accuracy is not enough.
I can not either multiply 4.9542 * 10000 and recreate the shift variable, because the variable is type of Float and I would not get as a result 4.9542 * 10000 = 40000 (if I'm not mistaken).
Please, how can I do? Do you have an example ?
Thank you in advance for your replies