petesouthwest wrote:
> In the working app I get:
> (Byte(Result[I]) + Seed) * Word(C1) + Word(C2)=1763724594
> 
> and seed gets assigned 19762
> 
> while in my new app that raises an exception with 'range check
> error'

If you have range checking turned on (check your compiler options) then 
an ERangeError exception is exactly what you should get. A Word variable 
can't hold a value of 1.7 billion.

> My delphi help says that the range of a word is 0..65535, so I would
> have thought neither example should run.
> 
> So I dont understand why this works, or why the test app assigns seed
> a value of 19762 while my other app creates an exception.

Range checking it probably only enabled in one of the programs.

You have three options:

1. Turn off range checking for the whole program. I don't recommend this.

2. Turn off range checking only for the line that's giving you trouble, 
like this:

{$R-}
Seed := (Byte(Result[I]) + Seed) * Word(C1) + Word(C2);
{$R+}

3. Type-cast the expression to Word:

Seed := Word((Byte(Result[I]) + Seed) * Word(C1) + Word(C2));

> I've tried posting on the Borland newsgroups in the hope that the chap
> from teamB can explain it to me, but not had an answer.

This might explain why:

http://www.cs.wisc.edu/~rkennedy/borland-newsgroups

-- 
Rob


-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to