Jump to content
Sign in to follow this  

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?



Share this post

Link to post
Share on other sites



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


Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

Sign in to follow this  

  • Create New...