Probably not, since some additions may overflow a UInt16. Some judicious
casts to (unsigned long) should make it work, however. I need to figure out
where the casts are needed.
In fact, even the old code wouldn't work with UInt16 values. Take the
crucial line from the old code (from memory):
x = ( l + r ) / 2.
If l = 0x8001 and r = 0x8003 then x is set to 2 instead of 0x8002. So one
needs a cast to ( unsigned long ) here for l and r.
One quick way to fix the code would be to declare lower and upper as UInt32,
but I prefer explicit casts where they are needed. I'll look where they're
needed when I have some leisure.
I did carefully check that all the comparisons and subtractions are
mathematically OK for unsigned values, but I didn't think of the overflow
problem (just as the old code didn't).
Alex
--
Dr. Alexander R. Pruss
Department of Philosophy
Georgetown University
Washington, DC 20057-1133 U.S.A.
e-mail: [EMAIL PROTECTED]
online papers and home page: www.georgetown.edu/faculty/ap85
--------------------------------------------------------------------------
"Philosophiam discimus non ut tantum sciamus, sed ut boni efficiamur."
- Paul of Worczyn (1424)
----- Original Message -----
From: "Michael Nordstrom" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 21, 2003 1:29 PM
Subject: Re: Remove optimize code from SearchVFSDocument
> On Tue, Oct 21, 2003, Alexander R. Pruss wrote:
> > if ( uidUpper == 0 ) {
> > uidUpper = GetVFSMaxUID();
> > if ( uidUpper < uid ) {
> > return NULL;
> > }
> > }
>
> Seems to work OK, but before the "optimize" code is off-the-hook I
> would like to get an answer to the question I have asked a few times
> now; will the optimize code be OK also after the previously signed
> variables have been changed to unsigned variables (to fix another bug
> in the optimize code)?
>
> /Mike
>
> _______________________________________________
> plucker-dev mailing list
> [EMAIL PROTECTED]
> http://lists.rubberchicken.org/mailman/listinfo/plucker-dev
>
_______________________________________________
plucker-dev mailing list
[EMAIL PROTECTED]
http://lists.rubberchicken.org/mailman/listinfo/plucker-dev