This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix for logb/logbf/logbl (bz 13954/13955/13956)


From: Andreas Jaeger <aj@suse.com>
Date: Wed, 2 May 2012 14:15:51 +0200

> On Tuesday, May 01, 2012 22:07:00 Adhemerval Zanella wrote:
>> On 05/01/2012 09:38 AM, Adhemerval Zanella wrote:
>> >> What about the dbl-64/wordsize-64, ldbl-96 and ldbl-128 routines? Do
>> >> they have the same problem and need fixing as well?
>> >> Your code change looks fine. Could you check the other
>> >> implementations as well and resubmit then?
>> > 
>> > I didn't check on above implementation but I'll do.
>> 
>> I have added fixes for 'dbl-64/wordsize-64', 'ldbl-96' and 'ldbl-128',
>> although for 'ldbl-128' I could not test (anyone to help me on this?).
>> For 'dbl-64/wordsize-64' I have tested on PPC64 and for 'ldbl-96' on
>> i386 and x86_64.
> 
> grepping Implies for ldbl-128 reveals:
> 
> So, let's ask Dave and Andreas for testing of this patch,

Well, first it didn't even build, here's a fix for that:

--- a/sysdeps/ieee754/ldbl-128/s_logbl.c~	2012-05-02 16:55:43.650725269 -0700
+++ b/sysdeps/ieee754/ldbl-128/s_logbl.c	2012-05-02 17:04:49.200630094 -0700
@@ -42,7 +42,7 @@ __logbl (long double x)
       /* POSIX specifies that denormal number is treated as
          though it were normalized.  */
       int m1 = (hx == 0) ? 0 : __builtin_clzl (hx);
-      int m2 = (lx == 0) ? 0 : __builtin_clz; (lx);
+      int m2 = (lx == 0) ? 0 : __builtin_clzl (lx);
       int ma = (m1 == 0) ? m2 + 64 : m1;
       return -16382.0 + (long double)(15 - ma);
     }

Next, all the logb tests fail for long double on sparc, see
the attached math/test-ldouble.out:
testing long double (without inline functions)
Failure: Test: logb (1) == 0
Result:
 is:          4.61140454345066086500e+18   0x1.fff7fffffffe00080000p+61
 should be:   0.00000000000000000000e+00   0x0.00000000000000000000p+0
 difference:  4.61140454345066086500e+18   0x1.fff7fffffffe00080000p+61
 ulp       :  23943781324392097443531535238309826495901781238743040.0000
 max.ulp   :  0.0000
Failure: Test: logb (e) == 1
Result:
 is:          4.61178710760784011900e+18   0x1.00016fc2a2c415dc0000p+62
 should be:   1.00000000000000000000e+00   0x1.00000000000000000000p+0
 difference:  4.61178710760784011800e+18   0x1.00016fc2a2c415d80000p+62
 ulp       :  23945767711063607302907167260243703153453982000611328.0000
 max.ulp   :  0.0000
Failure: Test: logb (1024) == 10
Result:
 is:          4.61421929321776742500e+18   0x1.0023ffffffff00040000p+62
 should be:   1.00000000000000000000e+01   0x1.40000000000000000000p+3
 difference:  4.61421929321776741500e+18   0x1.0023fffffffeffdc0000p+62
 ulp       :  2994799542595675802598825437661089130099172158996480.0000
 max.ulp   :  0.0000
Failure: Test: logb (-2000) == 10
Result:
 is:          4.61448757405494476900e+18   0x1.0027cfffffff00040000p+62
 should be:   1.00000000000000000000e+01   0x1.40000000000000000000p+3
 difference:  4.61448757405494475900e+18   0x1.0027cffffffeffdc0000p+62
 ulp       :  2994973666814185929704314548549361968505810854084608.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x0.1p-127) == -131
Result:
 is:          4.57453132150156492900e+18   0x1.fbdffffffffe00080000p+61
 should be:  -1.31000000000000000000e+02  -0x1.06000000000000000000p+7
 difference:  4.57453132150156506000e+18   0x1.fbdffffffffe04200000p+61
 ulp       :  185565036014857420636232351510050099670483384401920.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x0.01p-127) == -135
Result:
 is:          4.57340542159472230500e+18   0x1.fbbffffffffe00080000p+61
 should be:  -1.35000000000000000000e+02  -0x1.0e000000000000000000p+7
 difference:  4.57340542159472244000e+18   0x1.fbbffffffffe04400000p+61
 ulp       :  185519364088690830082297763188241079217697146798080.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x0.011p-127) == -135
Result:
 is:          4.57342301378076672100e+18   0x1.fbc07ffffffe00080000p+61
 should be:  -1.35000000000000000000e+02  -0x1.0e000000000000000000p+7
 difference:  4.57342301378076685600e+18   0x1.fbc07ffffffe04400000p+61
 ulp       :  185520077712537183062238292331225803965265338171392.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x0.8p-1022) == -1023
Result:
 is:          4.32345564227565977700e+18   0x1.dffffffffffe00080000p+61
 should be:  -1.02300000000000000000e+03  -0x1.ff800000000000000000p+9
 difference:  4.32345564227566080000e+18   0x1.dffffffffffe20000000p+61
 ulp       :  43845049119926931777204788936659634674788099686400.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x0.1p-1022) == -1026
Result:
 is:          4.32261121734552780900e+18   0x1.dfe7fffffffe00080000p+61
 should be:  -1.02600000000000000000e+03  -0x1.00800000000000000000p+10
 difference:  4.32261121734552883500e+18   0x1.dfe7fffffffe20180000p+61
 ulp       :  21918242816885348024171026813160221669945340067840.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x0.00111p-1022) == -1034
Result:
 is:          4.32037810922951475300e+18   0x1.dfa887fffffe00080000p+61
 should be:  -1.03400000000000000000e+03  -0x1.02800000000000000000p+10
 difference:  4.32037810922951578700e+18   0x1.dfa887fffffe20580000p+61
 ulp       :  21906919613510794140835731259510625312285181083648.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x0.00001p-1022) == -1042
Result:
 is:          4.31810761771815731300e+18   0x1.df67fffffffe00080000p+61
 should be:  -1.04200000000000000000e+03  -0x1.04800000000000000000p+10
 difference:  4.31810761771815835500e+18   0x1.df67fffffffe20980000p+61
 ulp       :  21895406853802052747203732652255711443552221265920.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x0.000011p-1022) == -1042
Result:
 is:          4.31812520990420172900e+18   0x1.df687ffffffe00080000p+61
 should be:  -1.04200000000000000000e+03  -0x1.04800000000000000000p+10
 difference:  4.31812520990420277100e+18   0x1.df687ffffffe20980000p+61
 ulp       :  21895496056782846869696298795128802036998245187584.0000
 max.ulp   :  0.0000
Failure: Test: logb (0x0.0000000000001p-1022) == -1074
Result:
 is:          4.30910041846341632100e+18   0x1.de67fffffffe00080000p+61
 should be:  -1.07400000000000000000e+03  -0x1.0c800000000000000000p+10
 difference:  4.30910041846341739500e+18   0x1.de67fffffffe21980000p+61
 ulp       :  21849734927635462193269144330446690990765983662080.0000
 max.ulp   :  0.0000
Maximal error of `logb'
 is      : 23945767711063607302907167260243703153453982000611328 ulp
 accepted: 0 ulp
Failure: Test: logb_downward (1.000e+0) == +0
Result:
 is:          4.61140454345066086500e+18   0x1.fff7fffffffe00080000p+61
 should be:   0.00000000000000000000e+00   0x0.00000000000000000000p+0
 difference:  4.61140454345066086500e+18   0x1.fff7fffffffe00080000p+61
 ulp       :  23943781324392097443531535238309826495901781238743040.0000
 max.ulp   :  0.0000
Maximal error of `logb_downward'
 is      : 23943781324392097443531535238309826495901781238743040 ulp
 accepted: 0 ulp

Test suite completed:
  5360 test cases plus 4492 tests for exception flags executed.
  16 errors occurred.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]