byte x = 0x25 //i used hex values to see if i can store 9600, baud, into an eeprom. just as a test. byte y = 0x80 // hex, 0x2850 is 9600int z;z = (int)(word(x, y));
byte x = 28 //i used hex values to see if i can store 9600, baud, into an eeprom. just as a test. byte y = 50 // hex, 0x2850 is 9600
but I suppose bit shifting is easier on the FPU
Quotebut I suppose bit shifting is easier on the FPUYour Arduino has a floating point unit? That's a pretty rare add on. Where did you get it?
Actually 9600 is 0x2580This operation is a lot faster if you just do this:byte x = 0x25;byte y = 0x80;int z;z = ( x << 8 ) + y;
Multiplying the MSB by 256 and adding the LSB doesn't require any magic function.Shifting the MSB left by 8 and adding the LSB achieves the same result, and requires no magic function.Learning HOW the magic functions work is better than stumbling over the magic functions.
yes, sorry was coding from memory
One tip for the future is to NEVER code from memory if you're asking for help. People will spend more time fixing the mistakes that are caused by coding from memory than the actual issue you are having.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16