[fpc-pascal] type conversions

memsom at interalpha.co.uk memsom at interalpha.co.uk
Mon Dec 9 13:30:40 CET 2002

> How can TList.count return a -1 ? Normally, this cannot happen.

I checked it out in Delphi.

  a: integer;
  b: cardinal;
  a := 0 -1; //fine.. like we all hoped ;-)
  b := 0 -1; //will not compile... gives an error concerning bounds

  b := 0;
  b := b -1; // no error

  showmessage(  format( '%d %1:d %1:u', [a, b] )  ); // shows '-1 -1 4294967295'

So Jonas is correct, in so much as the value in memory is the same, but the 
compiler interprets it differently for signed/unsigned types.

I think, at the end of the day, the error produces the same result whether the 
value is '0' or 65535... though I admit I didn't understand how FPC interprets -
1 as an unsigned value ;-)


This message was sent using Mistral WebMail.

More information about the fpc-pascal mailing list