[fpc-pascal] type conversions

Jonas Maebe jonas at zeus.rug.ac.be
Mon Dec 9 11:27:11 CET 2002

On maandag, dec 9, 2002, at 11:19 Europe/Brussels, 
memsom at interalpha.co.uk wrote:

> Um, unsigned... this will always equate to 0 if the count is 0 because 
> an
> *unsigned* number can _only_ hold positive numbers (0..n, *not* -n..(n 
> -1)). So
> 0 -1 can only be 0 because 0 is the smallest number the variable can 
> hold.

No, a type conversion between ordinal types does not change one bit 
pattern into another. -1 is a bit pattern that only contains 1-bits, so 
when you convert that to an unsigned type, it still contains only 
1-bits and as such becomes the highest value that that unsigned type 
can represent (65535 in case of an unsigned 16 variable).


More information about the fpc-pascal mailing list