- 2009.10.28 16:02 "Re: [Tiff] extending tags in "a"ppend mode?", by Frank Warmerdam
- 2009.11.03 12:16 "Re: [Tiff] Tiffcrop test suite and logluv issues", by Toby Thain
2009.11.04 08:45 "Re: [Tiff] Tiffcrop test suite and logluv issues", by Juergen Buchmueller
On Tue, 3 Nov 2009 12:46:26 -0800
From Toby Thain <toby@telegraphics.com.au>, Tue, Nov 03, 2009 at 07:16:07AM -0500:
>
> Alternatively one could write:> tp[i] = 65536 * bp[0] + 256 * bp[1] + bp[2];
>
> Compilers today transform the power-of-two multiplications into rather > effective code (read: shift lefts) and it doesn't require parens.
This adds to the cognitive load for humans. A shift shows the intent more clearly.
True.
One way of reducing the cognitive load in the multiply version is to use hex constants:
tp[i] = 0x10000 * bp[0] + 0x100 * bp[1] + bp[2];
which show the intent more clearly than the decimal constants.
I don't agree, but that may be due to me recognizing powers of two in decimal just as well as in hex.. at least up to 2^20.
Here's a suggestion for the ambitious commenter:
#define SHL24(x) 0x1000000*(x)
#define SHL16(x) 0x10000*(x)
#define SHL8(x) 0x100*(x)
tp[i] = SHL16(bp[0]) + SHL8(bp[1]) + bp[2];
;-)
Juergen