Re: sin() implementation

2017-09-29 Thread Joerg Sonnenberger
On Fri, Sep 29, 2017 at 11:16:24AM +0200, Alexandre Ratchov wrote: > On Wed, Sep 27, 2017 at 03:09:48PM +0200, Joerg Sonnenberger wrote: > > On Wed, Sep 27, 2017 at 08:40:26AM +0200, Alexandre Ratchov wrote: > > > Even on modern amd64s integer arithmetics and bitwise operations are > > > faster (an

Re: sin() implementation

2017-09-29 Thread Alexandre Ratchov
On Fri, Sep 29, 2017 at 11:28:42AM +0200, Otto Moerbeek wrote: > On Fri, Sep 29, 2017 at 11:16:24AM +0200, Alexandre Ratchov wrote: > > > On Wed, Sep 27, 2017 at 03:09:48PM +0200, Joerg Sonnenberger wrote: > > > On Wed, Sep 27, 2017 at 08:40:26AM +0200, Alexandre Ratchov wrote: > > > > Even on mod

Re: sin() implementation

2017-09-29 Thread Otto Moerbeek
On Fri, Sep 29, 2017 at 11:16:24AM +0200, Alexandre Ratchov wrote: > On Wed, Sep 27, 2017 at 03:09:48PM +0200, Joerg Sonnenberger wrote: > > On Wed, Sep 27, 2017 at 08:40:26AM +0200, Alexandre Ratchov wrote: > > > Even on modern amd64s integer arithmetics and bitwise operations are > > > faster (a

Re: sin() implementation

2017-09-29 Thread Alexandre Ratchov
On Wed, Sep 27, 2017 at 03:09:48PM +0200, Joerg Sonnenberger wrote: > On Wed, Sep 27, 2017 at 08:40:26AM +0200, Alexandre Ratchov wrote: > > Even on modern amd64s integer arithmetics and bitwise operations are > > faster (and more precise in many cases) than floating point > > equivalents. > > Can

Re: sin() implementation

2017-09-27 Thread Theo de Raadt
> On Wed, Sep 27, 2017 at 08:40:26AM +0200, Alexandre Ratchov wrote: > > Even on modern amd64s integer arithmetics and bitwise operations are > > faster (and more precise in many cases) than floating point > > equivalents. > > Can you actually substanciate this claim? The basic x87 instructions >

Re: sin() implementation

2017-09-27 Thread Joerg Sonnenberger
On Wed, Sep 27, 2017 at 08:40:26AM +0200, Alexandre Ratchov wrote: > Even on modern amd64s integer arithmetics and bitwise operations are > faster (and more precise in many cases) than floating point > equivalents. Can you actually substanciate this claim? The basic x87 instructions (FLD, FST, FCO

Re: sin() implementation

2017-09-26 Thread Alexandre Ratchov
On Tue, Sep 26, 2017 at 01:27:52PM +0200, Jan Stary wrote: > I picked sin() as an example while trying to walk though the implementation > of (pieces of) libm. If someone has the time for it, I have some questions. > > I understand the implementation originaly stems from Sun's libm of 1993. > (As

Re: sin() implementation

2017-09-26 Thread Jimmy Hess
On Tue, Sep 26, 2017 at 6:27 AM, Jan Stary wrote: > s_sin.c normalizes the argument to [-pi/4, +pi/4]. > This is how |x| <= pi/4 is tested: > GET_HIGH_WORD(ix,x); > ix &= 0x7fff; > if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); > > Why is it done like that? Is it fa

Re: sin() implementation

2017-09-26 Thread Otto Moerbeek
On Tue, Sep 26, 2017 at 01:27:52PM +0200, Jan Stary wrote: > I picked sin() as an example while trying to walk though the implementation > of (pieces of) libm. If someone has the time for it, I have some questions. > > I understand the implementation originaly stems from Sun's libm of 1993. > (A

Re: sin() implementation

2017-09-26 Thread Otto Moerbeek
On Tue, Sep 26, 2017 at 06:21:16PM +0200, Jan Stary wrote: > These (diff below) seem to be obvious typos in k_sin.c, > but only in comments. The comment that says > > if x < 2^-27 (hx<0x3e40), return x with inexact if x!=0 > > also puzzles me a bit: what the code does is > > GET

Re: sin() implementation

2017-09-26 Thread Jan Stary
On Sep 26 17:41:17, h...@stare.cz wrote: > > > s_sin.c normalizes the argument to [-pi/4, +pi/4]. > > > This is how |x| <= pi/4 is tested: > > > > > > GET_HIGH_WORD(ix,x); > > > ix &= 0x7fff; > > > if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); > > > > > > Why is it done like that? Is

Re: sin() implementation

2017-09-26 Thread Jan Stary
These (diff below) seem to be obvious typos in k_sin.c, but only in comments. The comment that says if x < 2^-27 (hx<0x3e40), return x with inexact if x!=0 also puzzles me a bit: what the code does is GET_HIGH_WORD(ix,x); ix &= 0x7fff; /* hig

Re: sin() implementation

2017-09-26 Thread Jan Stary
> > s_sin.c normalizes the argument to [-pi/4, +pi/4]. > > This is how |x| <= pi/4 is tested: > > > > GET_HIGH_WORD(ix,x); > > ix &= 0x7fff; > > if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); > > > > Why is it done like that? Is it faster or more portable > > or in any way bette

Re: sin() implementation

2017-09-26 Thread Jan Stary
On Sep 26 13:27:52, h...@stare.cz wrote: > I picked sin() as an example while trying to walk though the implementation > of (pieces of) libm. If someone has the time for it, I have some questions. > > I understand the implementation originaly stems from Sun's libm of 1993. > (As does that of Free

sin() implementation

2017-09-26 Thread Jan Stary
I picked sin() as an example while trying to walk though the implementation of (pieces of) libm. If someone has the time for it, I have some questions. I understand the implementation originaly stems from Sun's libm of 1993. (As does that of FreeBSD and NetBSD.) It has been tweaked over the years