Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / ia64 / fpu / printf_fphex.c
blob231b69d6e3464237859d9e4e8c9bc66f1c558be5
1 /* Print floating point number in hexadecimal notation according to ISO C99.
2 Copyright (C) 2000, 2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef LONG_DOUBLE_DENORM_BIAS
20 # define LONG_DOUBLE_DENORM_BIAS (IEEE854_LONG_DOUBLE_BIAS - 1)
21 #endif
23 #define PRINT_FPHEX_LONG_DOUBLE \
24 do { \
25 /* The "strange" 80 bit format on ia64 has an explicit \
26 leading digit in the 64 bit mantissa. */ \
27 unsigned long long int num; \
29 num = (((unsigned long long int) fpnum.ldbl.ieee.mantissa0) << 32 \
30 | fpnum.ldbl.ieee.mantissa1); \
32 zero_mantissa = num == 0; \
34 numstr = _itoa_word (num, numbuf + sizeof numbuf, 16, \
35 info->spec == 'A'); \
36 wnumstr = _itowa_word (num, \
37 wnumbuf + sizeof (wnumbuf) / sizeof (wchar_t), \
38 16, info->spec == 'A'); \
40 /* Fill with zeroes. */ \
41 while (numstr > numbuf + (sizeof numbuf - 64 / 4)) \
42 { \
43 *--numstr = '0'; \
44 *--wnumstr = L'0'; \
45 } \
47 /* We use a full nibble for the leading digit. */ \
48 leading = *numstr++; \
50 /* We have 3 bits from the mantissa in the leading nibble. \
51 Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'. */ \
52 exponent = fpnum.ldbl.ieee.exponent; \
54 if (exponent == 0) \
55 { \
56 if (zero_mantissa) \
57 expnegative = 0; \
58 else \
59 { \
60 /* This is a denormalized number. */ \
61 expnegative = 1; \
62 /* This is a hook for the m68k long double format, where the \
63 exponent bias is the same for normalized and denormalized \
64 numbers. */ \
65 exponent = LONG_DOUBLE_DENORM_BIAS + 3; \
66 } \
67 } \
68 else if (exponent >= IEEE854_LONG_DOUBLE_BIAS + 3) \
69 { \
70 expnegative = 0; \
71 exponent -= IEEE854_LONG_DOUBLE_BIAS + 3; \
72 } \
73 else \
74 { \
75 expnegative = 1; \
76 exponent = -(exponent - (IEEE854_LONG_DOUBLE_BIAS + 3)); \
77 } \
78 } while (0)
80 #include <stdio-common/printf_fphex.c>