Go Down

Topic: docs error? - rightmost vs leftmost (Read 713 times) previous topic - next topic

bitbangerbob

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!"

mellis

Whoops, fixed.

Let me know if I missed any places.

Professor Chaos

#2
Nov 30, 2009, 08:34 am Last Edit: Nov 30, 2009, 08:36 am by lefstin Reason: 1
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: [Select]
#define loByte (byte)lowByte
#define hiByte (byte)highByte

to cast away the problem.

Go Up