Pages: [1]   Go Down
Author Topic: docs error? - rightmost vs leftmost  (Read 690 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the extended language reference for word, highByte and lowByte, the low-order byte is referred to as "leftmost" and the high-order byte as "rightmost".  This is backwards, to my way of thinking.

int myval = 0xABCD;
Serial.println(lowByte(myval), HEX);
prints "CD" and

Serial.println(highByte(myval), HEX);
prints "AB"

I searched the site for highByte and lowByte and did not see any other instances of this usage.

As I tell my boss, "If I were perfect, you couldn't afford me!"

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
Karma: 12
Posts: 3538
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Whoops, fixed.

Let me know if I missed any places.

Offline Offline
Full Member
Karma: 1
Posts: 225
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not exactly the same subject, but the last time I checked highByte and lowByte actually returned int, not byte values.

I have only had a problem with this passing values to a function that expects either (int, int) or (byte, byte) as parameters.  If you pass a real byte and a lowByte(x), the compiler sees (byte, int) and can't resolve which overload you want.

My solution was to define macros:
#define loByte (byte)lowByte
#define hiByte (byte)highByte
to cast away the problem.
« Last Edit: November 30, 2009, 02:36:42 am by lefstin » Logged

Pages: [1]   Go Up
Jump to: