Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180923040244.GJ17995@brightrain.aerifal.cx>
Date: Sun, 23 Sep 2018 00:02:44 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: un-UBify-strings

On Sun, Sep 23, 2018 at 03:44:46AM +0000, Pascal Cuoq wrote:
> 
> > On 23 Sep 2018, at 05:15, Rich Felker <dalias@...c.org> wrote:
> > 
> > dist(s,d)==n is a no-overlap case.
> 
> In this case the formula I proposed has the drawback of rejecting
> the case where (uintptr_t)s-(uintptr_t)d is exactly -n. This case
> may be the justification for the way the original comparison was
> expressed:

I think that's fixable just by subtracting 1 on both sides, but then
it's probably less efficient rather than more efficient.

> > (uintptr_t)s-(uintptr_t)d-n <= -2*n
> 
> (uintptr_t)s-(uintptr_t)d = -n   ==> comparison true by LHS and RHS being equal
> 
> (uintptr_t)s-(uintptr_t)d = n    ==> comparison true by LHS being zero
> 
> (uintptr_t)s-(uintptr_t)d > -n and (uintptr_t)s-(uintptr_t)d < n  ==> comparison false

Yes. It's interesting that the choice of using left or right of 0
depends on whether you want > or >=.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.