1. 17 8月, 2020 1 次提交
  2. 31 10月, 2014 1 次提交
    • S
      fix rint.c and rintf.c when FLT_EVAL_METHOD!=0 · 79ca8609
      Szabolcs Nagy 提交于
      The old code used the rounding idiom incorrectly:
      
        y = (double)(x + 0x1p52) - 0x1p52;
      
      the cast is useless if FLT_EVAL_METHOD==0 and causes a second rounding
      if FLT_EVAL_METHOD==2 which can give incorrect result in nearest rounding
      mode, so the correct idiom is to add/sub a power-of-2 according to the
      characteristics of double_t.
      
      This did not cause actual bug because only i386 is affected where rint
      is implemented in asm.
      
      Other rounding functions use a similar idiom, but they give correct
      results because they only rely on getting a neighboring integer result
      and the rounding direction is fixed up separately independently of the
      current rounding mode. However they should be fixed to use the idiom
      correctly too.
      79ca8609
  3. 05 9月, 2013 1 次提交
    • S
      math: rewrite rounding functions (ceil, floor, trunc, round, rint) · d1a2ead8
      Szabolcs Nagy 提交于
      * faster, smaller, cleaner implementation than the bit hacks of fdlibm
      * use arithmetics like y=(double)(x+0x1p52)-0x1p52, which is an integer
      neighbor of x in all rounding modes (0<=x<0x1p52) and only use bithacks
      when that's faster and smaller (for float it usually is)
      * the code assumes standard excess precision handling for casts
      * long double code supports both ld80 and ld128
      * nearbyint is not changed (it is a wrapper around rint)
      d1a2ead8
  4. 13 3月, 2012 1 次提交
    • R
      first commit of the new libm! · b69f695a
      Rich Felker 提交于
      thanks to the hard work of Szabolcs Nagy (nsz), identifying the best
      (from correctness and license standpoint) implementations from freebsd
      and openbsd and cleaning them up! musl should now fully support c99
      float and long double math functions, and has near-complete complex
      math support. tgmath should also work (fully on gcc-compatible
      compilers, and mostly on any c99 compiler).
      
      based largely on commit 0376d44a890fea261506f1fc63833e7a686dca19 from
      nsz's libm git repo, with some additions (dummy versions of a few
      missing long double complex functions, etc.) by me.
      
      various cleanups still need to be made, including re-adding (if
      they're correct) some asm functions that were dropped.
      b69f695a