[fpc-pascal] Range check error while evaluating constants

Peter peter at pblackman.plus.com
Tue Oct 30 20:56:17 CET 2012


On 30/10/12 14:26, ik wrote:
> Hello,
>
> I have the following function:
>
> function OneToTwoComplement(AValue: QWord): QWord;
> begin
>    Result := (AValue xor $FFFFFFFFFFFFFFFF) + 1;
> end;
>
> What am I missing here that makes the compiler complain about "Range
> check error while evaluating constants" ?
> Why doesn't it complain on :
>
> function OneToTwoComplement(AValue: Int64): Int64;
> begin
>    Result := (Abs(AValue) xor $FFFFFFFFFFFFFFFF) + 1;
> end;
>
>
> Thanks,
> Ido
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>

See http://mantis.freepascal.org/view.php?id=21284

You need something like

function OneToTwoComplement(AValue: QWord): QWord;
begin
   Result := (AValue xor Qword($FFFFFFFFFFFFFFFF)) + 1;
end;




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20121030/93334337/attachment.html>


More information about the fpc-pascal mailing list