Arduino Using EEPROM

you can see the EEPROM as a line of boxes - each box can hold 1 byte. The put() function will look at how many bytes are needed for your parameter (for example 4 bytes for your float on a UNO) and if you ask to save your float starting at box #0 then it will fill Boxes #0 #1 #2 and #3.

The following diagram is a visual representation of the above text description.

Figure-1: Conceptual view of the internal structure of EEPROM of ATmega328P MCU

Example-1: Let us save 21 decimal (0x15 in hex) into Box-1 with address 1 indecimal (0x0001 in hex).

EEPROM.write(1, 21);
==> EEPROM.write(0x0001, 0x15);

==> #define   adr    1
==> #define   data   21
==> EEPROM.write(adr, data);

Example-2 Let us save 13.75 (decimal number with fractional point) into EEPROM.
In Example-1, we had 1-byte data; so, we required only 1-box to store the data. Now, we have less than 2-byte data; how many boxes we need to store this fractional value? More than 1-box but not 2-box. Then, how many boxes?

It is obvious that the boxed are single entity of their own; they can not be divided. The IEEE-754 Committee has decided that every floating point number (decimal number with fractional part) will be transformed into 32-bit (4-byte) 'Bit Pattern' known as binary32 formatted data, and this transformation takes place based on a definite rule/template (Fig-2).

Figure-2: binray32 format for representing a floating point number.

When we declare like flaot x = 13.75;, the compiler automatically applies the template of Fig-2 and produces a 32-bit bit pattern (0x415C0000) and saves in a buffer (temporary storage area). Now, we know that there will be a need of 4 memory locations of the EEPROM to store the number 13.75.

float x = 13.75;  //415C0000 is automatically created by compiler
EEPROM.put(0x03FB, x); //the 4-byte corresponding to 13.75 will be stored into locations: 03FB-03FE.

BTW: You may have curiosity how have I so quickly obtained the binary32 formatted value for 17.35. I have executed the following codes which have printed the hex value on the Serial Monitor.

void setup() 
{
  Serial.begin(9600);
  float x = 13.75;
  unsigned long *ptr;
  ptr = (unsigned long*) &x;
  unsigned long m = *ptr;
  Serial.println(m, HEX);   //show: 415C0000
}

void loop() 
{
  
}