Storing Double Precision Float in EEprom? | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar
Please consider registering
guest
sp_LogInOut Log In sp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
Storing Double Precision Float in EEprom?
September 3, 2019
4:17 pm
Avatar
Alan Kitching
Member
Members
Forum Posts: 9
Member Since:
August 16, 2019
sp_UserOfflineSmall Offline

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.

September 3, 2019
8:58 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

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.

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
4
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356