]>
Commit | Line | Data |
---|---|---|
d5efd131 | 1 | /* Print floating point number in hexadecimal notation according to ISO C99. |
dff8da6b | 2 | Copyright (C) 2000-2024 Free Software Foundation, Inc. |
d5efd131 MF |
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 | |
75efb018 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
d5efd131 MF |
18 | |
19 | #ifndef LONG_DOUBLE_DENORM_BIAS | |
20 | # define LONG_DOUBLE_DENORM_BIAS (IEEE854_LONG_DOUBLE_BIAS - 1) | |
21 | #endif | |
22 | ||
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; \ | |
1b6adf88 AM |
28 | union ieee854_long_double u; \ |
29 | u.d = fpnum.ldbl; \ | |
d5efd131 | 30 | \ |
1b6adf88 AM |
31 | num = (((unsigned long long int) u.ieee.mantissa0) << 32 \ |
32 | | u.ieee.mantissa1); \ | |
d5efd131 MF |
33 | \ |
34 | zero_mantissa = num == 0; \ | |
35 | \ | |
36 | numstr = _itoa_word (num, numbuf + sizeof numbuf, 16, \ | |
37 | info->spec == 'A'); \ | |
d5efd131 MF |
38 | \ |
39 | /* Fill with zeroes. */ \ | |
40 | while (numstr > numbuf + (sizeof numbuf - 64 / 4)) \ | |
e88b9f0e | 41 | *--numstr = '0'; \ |
d5efd131 MF |
42 | \ |
43 | /* We use a full nibble for the leading digit. */ \ | |
44 | leading = *numstr++; \ | |
45 | \ | |
46 | /* We have 3 bits from the mantissa in the leading nibble. \ | |
47 | Therefore we are here using `IEEE854_LONG_DOUBLE_BIAS + 3'. */ \ | |
1b6adf88 AM |
48 | exponent = u.ieee.exponent; \ |
49 | \ | |
d5efd131 MF |
50 | if (exponent == 0) \ |
51 | { \ | |
52 | if (zero_mantissa) \ | |
53 | expnegative = 0; \ | |
54 | else \ | |
55 | { \ | |
56 | /* This is a denormalized number. */ \ | |
57 | expnegative = 1; \ | |
58 | /* This is a hook for the m68k long double format, where the \ | |
59 | exponent bias is the same for normalized and denormalized \ | |
60 | numbers. */ \ | |
61 | exponent = LONG_DOUBLE_DENORM_BIAS + 3; \ | |
62 | } \ | |
63 | } \ | |
64 | else if (exponent >= IEEE854_LONG_DOUBLE_BIAS + 3) \ | |
65 | { \ | |
66 | expnegative = 0; \ | |
67 | exponent -= IEEE854_LONG_DOUBLE_BIAS + 3; \ | |
68 | } \ | |
69 | else \ | |
70 | { \ | |
71 | expnegative = 1; \ | |
72 | exponent = -(exponent - (IEEE854_LONG_DOUBLE_BIAS + 3)); \ | |
73 | } \ | |
74 | } while (0) | |
75 | ||
76 | #include <stdio-common/printf_fphex.c> |