This is the mail archive of the glibc-bugs@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]

[Bug libc/13941] New: printf of subnormal 'long double' numbers wrong on PowerPC


http://sourceware.org/bugzilla/show_bug.cgi?id=13941

             Bug #: 13941
           Summary: printf of subnormal 'long double' numbers wrong on
                    PowerPC
           Product: glibc
           Version: 2.11
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: bruno@clisp.org
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


printf on subnormal (denormalized) 'long double' numbers prints wrong values.

Test program: It printf 2^i as a long double, for -1000 >= i >= -1080.
============================= foo.c ============================
#include <stdio.h>
volatile long double x;
int main ()
{
  int i;
  for (i = 0, x = 1.0L; i >= -1080; i--, x *= 0.5L)
    if (i <= -1000)
      printf ("%d %Lg\n", i, x);
  return 0;
}
===============================================================
$ gcc -Wall foo.c
$ ./a.out

Expected output:
-1000 9.33264e-302
-1001 4.66632e-302
-1002 2.33316e-302
-1003 1.16658e-302
-1004 5.8329e-303
-1005 2.91645e-303
-1006 1.45822e-303
-1007 7.29112e-304
-1008 3.64556e-304
-1009 1.82278e-304
-1010 9.1139e-305
-1011 4.55695e-305
-1012 2.27848e-305
-1013 1.13924e-305
-1014 5.69619e-306
-1015 2.84809e-306
-1016 1.42405e-306
-1017 7.12024e-307
-1018 3.56012e-307
-1019 1.78006e-307
-1020 8.9003e-308
-1021 4.45015e-308
-1022 2.22507e-308
-1023 1.11254e-308
-1024 5.56268e-309
-1025 2.78134e-309
-1026 1.39067e-309
-1027 6.95336e-310
-1028 3.47668e-310
-1029 1.73834e-310
-1030 8.69169e-311
-1031 4.34585e-311
-1032 2.17292e-311
-1033 1.08646e-311
-1034 5.43231e-312
-1035 2.71615e-312
-1036 1.35808e-312
-1037 6.79039e-313
-1038 3.39519e-313
-1039 1.6976e-313
-1040 8.48798e-314
-1041 4.24399e-314
-1042 2.122e-314
-1043 1.061e-314
-1044 5.30499e-315
-1045 2.65249e-315
-1046 1.32625e-315
-1047 6.63124e-316
-1048 3.31562e-316
-1049 1.65781e-316
-1050 8.28905e-317
-1051 4.14452e-317
-1052 2.07226e-317
-1053 1.03613e-317
-1054 5.18065e-318
-1055 2.59033e-318
-1056 1.29516e-318
-1057 6.47582e-319
-1058 3.23791e-319
-1059 1.61895e-319
-1060 8.09477e-320
-1061 4.04739e-320
-1062 2.02369e-320
-1063 1.01185e-320
-1064 5.05923e-321
-1065 2.52962e-321
-1066 1.26481e-321
-1067 6.32404e-322
-1068 3.16202e-322
-1069 1.58101e-322
-1070 7.90505e-323
-1071 3.95253e-323
-1072 1.97626e-323
-1073 9.88131e-324
-1074 4.94066e-324
-1075 0
-1076 0
-1077 0
-1078 0
-1079 0
-1080 0

Actual output:

-1000 9.33264e-302
-1001 4.66632e-302
-1002 2.33316e-302
-1003 1.16658e-302
-1004 5.8329e-303
-1005 2.91645e-303
-1006 1.45822e-303
-1007 7.29112e-304
-1008 3.64556e-304
-1009 1.82278e-304
-1010 9.1139e-305
-1011 4.55695e-305
-1012 2.27848e-305
-1013 1.13924e-305
-1014 5.69619e-306
-1015 2.84809e-306
-1016 1.42405e-306
-1017 7.12024e-307
-1018 3.56012e-307
-1019 1.78006e-307
-1020 8.9003e-308
-1021 4.45015e-308
-1022 2.22507e-308
-1023 1.00208e-292
-1024 5.01042e-293
-1025 2.50521e-293
-1026 1.25261e-293
-1027 6.26303e-294
-1028 3.13151e-294
-1029 1.56576e-294
-1030 7.82878e-295
-1031 3.91439e-295
-1032 1.9572e-295
-1033 9.78598e-296
-1034 4.89299e-296
-1035 2.44649e-296
-1036 1.22325e-296
-1037 6.11624e-297
-1038 3.05812e-297
-1039 1.52906e-297
-1040 7.6453e-298
-1041 3.82265e-298
-1042 1.91132e-298
-1043 9.55662e-299
-1044 4.77831e-299
-1045 2.38915e-299
-1046 1.19458e-299
-1047 5.97289e-300
-1048 2.98644e-300
-1049 1.49322e-300
-1050 7.46611e-301
-1051 3.73305e-301
-1052 1.86653e-301
-1053 9.33264e-302
-1054 4.66632e-302
-1055 2.33316e-302
-1056 1.16658e-302
-1057 5.8329e-303
-1058 2.91645e-303
-1059 1.45822e-303
-1060 7.29112e-304
-1061 3.64556e-304
-1062 1.82278e-304
-1063 9.1139e-305
-1064 4.55695e-305
-1065 2.27848e-305
-1066 1.13924e-305
-1067 5.69619e-306
-1068 2.84809e-306
-1069 1.42405e-306
-1070 7.12024e-307
-1071 3.56012e-307
-1072 1.78006e-307
-1073 8.9003e-308
-1074 4.45015e-308
-1075 0
-1076 0
-1077 0
-1078 0
-1079 0
-1080 0

For i = -1023 ... -1074 the printed values are wrong by a factor of 2^53.

$ /lib/libc.so.6 
GNU C Library (Debian EGLIBC 2.11.2-10) stable release version 2.11.2, by
Roland McGrath et al.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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