While it may work if range checking is off it does not mean that the
value returned will be accurate.

Round returns an int64 which has a higher range than longint. When you
assign result to s with rangecheck off and the result is + or - beyond
the range of longint you are going to get a value inside longint range
rather than the required result value.

Ie

sI:Smallint (-126 -- +127)
B:byte;

B := 128;
Si := b;

B will now be something like -1. (I am not providing exact answer here
:) just showing kind of thing that happens)

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Alistair George
> Sent: Tuesday, 9 December 2003 2:22 p.m.
> To: [EMAIL PROTECTED]
> Subject: [DUG] IDE Range check error
> 
> 
> Hi All.
> I am wondering what the point of selecting  range checking 
> and overflow checking in Compiler options are when it brings 
> up what would seem to be invalid errors:
>   s: longint;
> begin
>     S := round(DTnum / 10000); //about every 20 seconds 
> <RANGE CHECK HERE BUT RESULT IF NOT CHECKED IS FINE.
> 
> 
> _______________________________________________
> Delphi mailing list
> [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
> 

_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to