Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-10

Range check error while evaluating constants

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

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

Reply by email

ik
to ik
ik wrote 21 lines
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

How I love to be completely ignored

Reply by email

geneb
to ik
ik wrote 24 lines
On Tue, Oct 30, 2012 at 4:26 PM, 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 How I love to be completely ignored

That's good, because we love ignoring you.

g.

Proud owner of F-15C 80-0007 http://www.f15sim.com - The only one of its kind. http://www.diy-cockpits.org/coll - Go Collimated or Go Home. Some people collect things for a hobby. Geeks collect hobbies. ScarletDME - The red hot Data Management Environment A Multi-Value database for the masses, not the classes. http://www.scarletdme.org - Get it _today_!

Reply by email

Peter
to ik: I have the following function: function OneToTwoComplement(AValue: QWord): QWord; begin…
ik wrote 25 lines
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 - 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;

Reply by email

Mark Morgan Lloyd
to ik: I have the following function: function OneToTwoComplement(AValue: QWord): QWord; begin…
ik wrote 17 lines
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;

What happens in the first case if you cast that constant to a QWord?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

ik
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 22 lines
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; What happens in the first case if you cast that constant to a QWord?

The compiler stop reporting warnings

Show quoted text 10 lines
-- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email