(__ieee754_sqrt): Remove unused variables b and n.
[kopensolaris-gnu/glibc.git] / sysdeps / ieee754 / ldbl-96 / printf_fphex.c
1 /* Print floating point number in hexadecimal notation according to ISO C99.
2    Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14
15    You should have received a copy of the GNU Library General Public
16    License along with the GNU C Library; see the file COPYING.LIB.  If not,
17    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18    Boston, MA 02111-1307, USA.  */
19
20 #ifndef LONG_DOUBLE_DENORM_BIAS
21 # define LONG_DOUBLE_DENORM_BIAS (IEEE854_LONG_DOUBLE_BIAS - 1)
22 #endif
23
24 #define PRINT_FPHEX_LONG_DOUBLE \
25 do {                                                                          \
26       /* The "strange" 80 bit format on ix86 and m68k has an explicit         \
27          leading digit in the 64 bit mantissa.  */                            \
28       unsigned long long int num;                                             \
29                                                                               \
30       assert (sizeof (long double) == 12);                                    \
31                                                                               \
32       num = (((unsigned long long int) fpnum.ldbl.ieee.mantissa0) << 32       \
33              | fpnum.ldbl.ieee.mantissa1);                                    \
34                                                                               \
35       zero_mantissa = num == 0;                                               \
36                                                                               \
37       if (sizeof (unsigned long int) > 6)                                     \
38         {                                                                     \
39           numstr = _itoa_word (num, numbuf + sizeof numbuf, 16,               \
40                                info->spec == 'A');                            \
41           wnumstr = _itowa_word (num,                                         \
42                                  wnumbuf + sizeof (wnumbuf) / sizeof (wchar_t),\
43                                  16, info->spec == 'A');                      \
44         }                                                                     \
45       else                                                                    \
46         {                                                                     \
47           numstr = _itoa (num, numbuf + sizeof numbuf, 16, info->spec == 'A');\
48           wnumstr = _itowa (num,                                              \
49                             wnumbuf + sizeof (wnumbuf) / sizeof (wchar_t),    \
50                             16, info->spec == 'A');                           \
51         }                                                                     \
52                                                                               \
53       /* Fill with zeroes.  */                                                \
54       while (numstr > numbuf + (sizeof numbuf - 64 / 4))                      \
55         {                                                                     \
56           *--numstr = '0';                                                    \
57           *--wnumstr = L'0';                                                  \
58         }                                                                     \
59                                                                               \
60       /* We use a full nibble for the leading digit.  */                      \
61       leading = *numstr++;                                                    \
62                                                                               \
63       /* We have 3 bits from the mantissa in the leading nibble.              \
64          Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'.  */      \
65       exponent = fpnum.ldbl.ieee.exponent;                                    \
66                                                                               \
67       if (exponent == 0)                                                      \
68         {                                                                     \
69           if (zero_mantissa)                                                  \
70             expnegative = 0;                                                  \
71           else                                                                \
72             {                                                                 \
73               /* This is a denormalized number.  */                           \
74               expnegative = 1;                                                \
75               /* This is a hook for the m68k long double format, where the    \
76                  exponent bias is the same for normalized and denormalized    \
77                  numbers.  */                                                 \
78               exponent = LONG_DOUBLE_DENORM_BIAS + 3;                         \
79             }                                                                 \
80         }                                                                     \
81       else if (exponent >= IEEE854_LONG_DOUBLE_BIAS + 3)                      \
82         {                                                                     \
83           expnegative = 0;                                                    \
84           exponent -= IEEE854_LONG_DOUBLE_BIAS + 3;                           \
85         }                                                                     \
86       else                                                                    \
87         {                                                                     \
88           expnegative = 1;                                                    \
89           exponent = -(exponent - (IEEE854_LONG_DOUBLE_BIAS + 3));            \
90         }                                                                     \
91 } while (0)
92
93 #include <sysdeps/generic/printf_fphex.c>