[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bit operations in PL47 localtim.c



I don't want to get into the habit of replying to my own posts,
but this may save someone else the trouble...

On Sat, 21 Jun 1997, Yves Pelletier wrote:

> 	result = (codep[0] & 0x80) ? ~0L : 0L;
> 	for (i = 0; i < 4; ++i)
> 		result = (result << 8) | (codep[i] & 0xff);
> 

Ok.  Stared at this long enough to let it permeate through my
thick skull,  and now I understand what it does.

Now 'result' is of type long; that type is 32 bits, under both
regular and short integer compiler models.  So there will always
be enough room in the long type, to store 4 one-byte characters. 
So this looks safe under both models. 

Yves