Subject | Integer Overflows |
---|---|

Author | hans@hoogstraat.ca |

Post date | 2002-01-31T17:26:50Z |

Hello Jason,

Hope I'm not repeating this messages, but it looked like

my messages have gone astray for a few days.

I found a small problem in IB_NodeList, which creates pesky

Integer Overflow errors in my tests.

===========================

procedure TIB_NodeList.SetRefToPos( var ARef: TIB_NodeRef;

const APos: longint;

AllowFetches: boolean );

function GetDif( const A, B: integer ): integer;

begin

try

Result := A - B;

except

on E: EIntOverflow do

Result := low( integer ); <---- 2147483648

end;

if Result = low( integer ) then

Result := high( integer )

else

if Result < 0 then

Result := -Result; <---- Overflow

end;

var

tmpRef: TIB_NodeRef;

===========================

InvalidNodeList is declared as -MaxInt = -2147483647 , however

Low(Integer) = 2147483648 and their exists no 2147483648, thus

Results := -Result; Overflows.

I just replaced

Result := low( integer );

by

Result := -high( integer );

and pesky Integer OverFlow Messages disappeared.

Best Regards

Hans

Hope I'm not repeating this messages, but it looked like

my messages have gone astray for a few days.

I found a small problem in IB_NodeList, which creates pesky

Integer Overflow errors in my tests.

===========================

procedure TIB_NodeList.SetRefToPos( var ARef: TIB_NodeRef;

const APos: longint;

AllowFetches: boolean );

function GetDif( const A, B: integer ): integer;

begin

try

Result := A - B;

except

on E: EIntOverflow do

Result := low( integer ); <---- 2147483648

end;

if Result = low( integer ) then

Result := high( integer )

else

if Result < 0 then

Result := -Result; <---- Overflow

end;

var

tmpRef: TIB_NodeRef;

===========================

InvalidNodeList is declared as -MaxInt = -2147483647 , however

Low(Integer) = 2147483648 and their exists no 2147483648, thus

Results := -Result; Overflows.

I just replaced

Result := low( integer );

by

Result := -high( integer );

and pesky Integer OverFlow Messages disappeared.

Best Regards

Hans