]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/x86_64/fpu/printf_fphex.c
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[thirdparty/glibc.git] / sysdeps / x86_64 / fpu / printf_fphex.c
CommitLineData
c9cf6dde 1/* Print floating point number in hexadecimal notation according to ISO C99.
a334319f 2 Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
c9cf6dde
AJ
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 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.
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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 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 \
25do { \
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 \
31 num = (((unsigned long long int) fpnum.ldbl.ieee.mantissa0) << 32 \
32 | fpnum.ldbl.ieee.mantissa1); \
33 \
34 zero_mantissa = num == 0; \
35 \
36 if (sizeof (unsigned long int) > 6) \
37 { \
38 numstr = _itoa_word (num, numbuf + sizeof numbuf, 16, \
39 info->spec == 'A'); \
40 wnumstr = _itowa_word (num, \
41 wnumbuf + sizeof (wnumbuf) / sizeof (wchar_t),\
42 16, info->spec == 'A'); \
43 } \
44 else \
45 { \
46 numstr = _itoa (num, numbuf + sizeof numbuf, 16, info->spec == 'A');\
47 wnumstr = _itowa (num, \
48 wnumbuf + sizeof (wnumbuf) / sizeof (wchar_t), \
49 16, info->spec == 'A'); \
50 } \
51 \
52 /* Fill with zeroes. */ \
53 while (numstr > numbuf + (sizeof numbuf - 64 / 4)) \
54 { \
55 *--numstr = '0'; \
56 *--wnumstr = L'0'; \
57 } \
58 \
59 /* We use a full nibble for the leading digit. */ \
60 leading = *numstr++; \
61 \
62 /* We have 3 bits from the mantissa in the leading nibble. \
63 Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'. */ \
64 exponent = fpnum.ldbl.ieee.exponent; \
65 \
66 if (exponent == 0) \
67 { \
68 if (zero_mantissa) \
69 expnegative = 0; \
70 else \
71 { \
72 /* This is a denormalized number. */ \
73 expnegative = 1; \
74 /* This is a hook for the m68k long double format, where the \
75 exponent bias is the same for normalized and denormalized \
76 numbers. */ \
77 exponent = LONG_DOUBLE_DENORM_BIAS + 3; \
78 } \
79 } \
80 else if (exponent >= IEEE854_LONG_DOUBLE_BIAS + 3) \
81 { \
82 expnegative = 0; \
83 exponent -= IEEE854_LONG_DOUBLE_BIAS + 3; \
84 } \
85 else \
86 { \
87 expnegative = 1; \
88 exponent = -(exponent - (IEEE854_LONG_DOUBLE_BIAS + 3)); \
89 } \
90} while (0)
91
a334319f 92#include <sysdeps/generic/printf_fphex.c>