Jump to content
Sign in to follow this  
chuckwsh

Storing Float In Eeprom

Recommended Posts

Anyone have a quick done routine to store a float to eeprom? I looked quite a bit and perhaps I didn't follow the setup or I missed something. thanks, or point me to where?

 

Chuck

Share this post


Link to post
Share on other sites

Hi

 

The easiest way I can think of storing and retrieving a variable in IEEE floating point format is byte by byte.

 

Just declare an "unsigned char pointer" and make it point to the variable of interest.

Use a loop from "0" to "sizeof( <float var> ) -1" to retrieve one byte at a time and store it in the EEPROM.

Use the same aproach to retrieve them back to a variable of the same type.

This way you don't have to worrie with the number and order of bytesin the variable.

This approach can be used with any kind of complex variables, not only IEEE formats but also structures and unions.

 

 

 

Best regards

Jorge

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×