PDA

View Full Version : Range error on minimal value of Longint



cronodragon
27-02-2008, 07:01 PM
I DON'T have problems with this code:

if (PInt64(Valor)^ >= -128) and (PInt64(Valor)^ <127>= -32768) and (PInt64(Valor)^ <32767>= 0) and (PInt64(Valor)^ <= 4294967295) then
...


But I'm getting an error on this one:

if (PInt64(Valor)^ >= -2147483648) and (PInt64(Valor)^ <= 2147483647) then
...

[Error] MSerie.pas(990): Overflow in conversion or arithmetic operation


According to Delphi's help Longint range is: -2147483648..2147483647

If I use -2147483647 it works! But why not with the full range? :? Any idea how to deal with that problem?

cronodragon
27-02-2008, 07:20 PM
Muahahahaha! I did it!

const
X: Longint = -2147483647-1;