if v then return n or (n<<16) else return n<<16)

---->

if v then return n*0x10000 + n else return n*0x10000

Mmm, I'm afraid not exactly.

While <<16 and *0x10000 are interchangeable and we may even drop the

*(v7_prop_attr_desc_t)* member of the macro painlessly because it's effectively just a cast of

*n* to an unsigned long (cf.

*typedef unsigned long v7_prop_attr_desc_t;*) to shut up the C compiler's strict type checking, we

may not substitute

*bitwise or* with

*addition* here.

So, both

**If v Then Return (n BitwiseOr (n << 16)) Else Return (n << 16)**and

**If v Then Return (n BitwiseOr (n * 0x10000)) Else Return (n * 0x10000)**are safe for any given

*n* and their combinations be they signed or unsigned, original or cast, as long as we're

shifting to the left. When shifting to the right, we must also be aware of signed or unsigned

*n* shifts. In the case of signed negative

*n*, C will preserve its highest-order bit (the leftmost one in Calculator's binary number representation, or the 31st one in the 0..31 bit range) in its place while right shifting. OTOH the highest-order bit of an unsigned

*n* will be right-shifted down together with the other bits in this number. So, right shifts, if any, is where the

*(v7_prop_attr_desc_t)* cast would also matter.

But at any rate, for such a dramatic headlong dash to the left

*addition* is

only usable up to a certain "pivot point" where the total of bits in

*n* wouldn't exceed 0xFFFF0000, because any attempt to

*add* yet another bit (i.e. property attribute) to the total rather than

*bitwise or* them together would yield an entirely wrong total:

#AppType Console

? "test 0xFFFF0000"

test(0xffff0000)

? "-------------------------"

? "test 0xFFFF0001"

test(0xffff0001)

DynC test(%n)

void main(int n)

{

printf(" signed + : %d\n", n

+ (n

<< 16)); printf(" unsigned + : %u\n", n

+ (n

<< 16)); printf("(unsigned) + : %u\n", (unsigned)n

+ ((unsigned)n

<< 16)); printf(" signed | : %d\n", n

| (n

<< 16)); printf(" unsigned | : %u\n", n

| (n

<< 16)); printf("(unsigned) | : %u\n", (unsigned)n

| ((unsigned)n

<< 16)); }

End DynC

Pause

Output:

test 0xFFFF0000

signed + : -65536

unsigned + : 4294901760

(unsigned) + : 4294901760

signed | : -65536

unsigned | : 4294901760

(unsigned) | : 4294901760

-------------------------

test 0xFFFF0001

signed + : 1 <== All wrong! 1 means V7_PROPERTY_NON_WRITABLE!

unsigned + : 1 <== ditto

(unsigned) + : 1 <== ditto

signed | : -65535

unsigned | : 4294901761

(unsigned) | : 4294901761