4:17 pm
August 16, 2019
I have searched the forum for this topic, but if I have missed it perhaps someone could point it out to me......
Otherwise, can any one tell me the correct way to store and retrieve a double precision floating point number in EEprom?
By using the "Number to Fractional String" and then "String to Byte Array" functions I have been able convert the Double Precision number to an array of U8s but I'm not sure if this is correct or robust.
Thanks
Alan K.
8:58 pm
March 12, 2015
Yes, this is probably the easiest way with the functions that are supported by the Compiler. The downside to this of course is that it will take a bit more memory in EEPROM because you are converting to ASCII and storing the ASCII representation of the number. You can reduce the number of bytes required by lowering the precision. If you stored it in binary, it will always only take 4 bytes for single precision (8 bytes for double). But there is no easy way to cast straight from a float to binary byte array. To do this you could incorporate these (EEPROM.put() and EEPROM.get()) Arduino library calls, you would just need to create a custom Compiler library for it.
4
1 Guest(s)