Pages: [1]   Go Down
Author Topic: docs error? - rightmost vs leftmost  (Read 668 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
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!"
Logged

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

Whoops, fixed.

Let me know if I missed any places.
Logged

0
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:
Code:
#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: