Post Reply 
Scientific RPN Calculator (with ATTINY85)
03-23-2018, 07:30 AM
Post: #43
RE: Scientific RPN Calculator (with ATTINY85)
Drop the memmove, the union does this for you.

You might get away this this ugly:
Code:
byte n = sizeof(double); 
while (n--) EEPROM.write(addr++, ((byte *)&x)[n - 1]);

This should be equivalent:
Code:
byte n = sizeof(double); 
while (n) EEPROM.write(addr++, ((byte *)&x)[--n]);

Although, personally I'd do:
Code:
for (byte n=0; n<sizeof(double); n++) EEPROM.write(addr++, ((byte *)&x)[n]);

or even:
Code:

byte *p = (byte *)&x;
for (byte n=0; n<sizeof(double); n++) EEPROM.write(addr++, *p++);

A reasonable compiler would treat them all the same but not every compiler is reasonable.


Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Scientific RPN Calculator (with ATTINY85) - Paul Dale - 03-23-2018 07:30 AM



User(s) browsing this thread: 1 Guest(s)