Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Oct 2005 21:07:23 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   cvs commit: src/lib/msun/src k_cosf.c
Message-ID:  <200510092107.j99L7Nor037424@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
bde         2005-10-09 21:07:23 UTC

  FreeBSD src repository

  Modified files:
    lib/msun/src         k_cosf.c 
  Log:
  Fix numerous errors of >= 1 ulp for cosf(x) and sinf(x) (1 line)
  and add a comment about related magic (many lines)).
  
  __kernel_cos[f]() needs a trick to reduce the error to below 1 ulp
  when |x| >= 0.3 for the range-reduced x.  Modulo other bugs, naive
  code that doesn't use the trick would have an error of >= 1 ulp
  in about 0.00006% of cases when |x| >= 0.3 for the unreduced x,
  with a maximum relative error of about 1.03 ulps.  Mistransation
  of the trick from the double precision case resulted in errors in
  about 0.2% of cases, with a maximum relative error of about 1.3 ulps.
  
  The mistranslation involved not doing implicit masking of the 32-bit
  float word corresponding to to implicit masking of the lower 32-bit
  double word by clearing it.
  
  sinf() uses __kernel_cosf() for half of all cases so its errors from
  this bug are similar.  tanf() is not affected.
  
  The error bounds in the above and in my other recent commit messages
  are for amd64.  Extra precision for floats on i386's accidentally masks
  this bug, but only if k_cosf.c is compiled with -O.  Although the extra
  precision helps here, this is accidental and depends on longstanding
  gcc precision bugs (not clipping extra precision on assignment...),
  and the gcc bugs are mostly avoided by compiling without -O.  I now
  develop libm mainly on amd64 systems to simplify error detection and
  debugging.
  
  Revision  Changes    Path
  1.8       +12 -1     src/lib/msun/src/k_cosf.c



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200510092107.j99L7Nor037424>