Re: >> to accelerate division
From: Richard Bos (rlb_at_hoekstra-uitgeverij.nl)
Date: 12/08/04
- Next message: Chris Menzel: "Re: Tautologies Then and Now"
- Previous message: Robin Chapman: "Re: topology question"
- In reply to: David Kastrup: "Re: >> to accelerate division"
- Next in thread: Andrey Tarasevich: "Re: >> to accelerate division"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 08 Dec 2004 10:30:58 GMT
David Kastrup <dak@gnu.org> wrote:
> Ben Pfaff <blp@cs.stanford.edu> writes:
>
> > You can implement i/3 as a multiplication followed by a bit
> > shift. In some cases this may be an improvement. However, if it
> > is an improvement, your compiler may already be doing it for you.
>
> Why not just write
>
> i *= 2863311531;
>
> As long as i is multiple of 3, this will work fine on 32bit machines.
Not if i is a signed int, it won't - at least, it's not guaranteed to.
Signed overflow has undefined behaviour.
Richard
- Next message: Chris Menzel: "Re: Tautologies Then and Now"
- Previous message: Robin Chapman: "Re: topology question"
- In reply to: David Kastrup: "Re: >> to accelerate division"
- Next in thread: Andrey Tarasevich: "Re: >> to accelerate division"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|