1 /****************************************************************
3 The author of this software is David M. Gay.
5 Copyright (C) 2009 by David M. Gay
8 Permission to use, copy, modify, and distribute this software and
9 its documentation for any purpose and without fee is hereby
10 granted, provided that the above copyright notice appear in all
11 source-code copies and that both that the copyright notice and this
12 permission notice and warranty disclaimer appear in supporting
15 THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
17 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
19 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21 PERFORMANCE OF THIS SOFTWARE.
23 ****************************************************************/
32 typedef union Ud
{double x
; unsigned int u
[2]; } Ud
;
33 #ifdef __x86_64 /*{{*/
35 #ifndef NO_GDTOA_i386_Quad /*{*/
36 typedef union UQ
{__float128 x
; unsigned int u
[4]; } UQ
;
37 #define allow_Quad(x) x
45 typedef union UQ
{long double x
; unsigned int u
[4]; } Ux
;
47 #ifdef __INTEL_COMPILER /*{*/
57 #define allow_Quad(x) /*nothing*/
61 typedef union Ux
{long double x
; unsigned short u
[5]; } Ux
;
73 char *b
, buf
[256], fmt
[32], *s
;
84 while(fgets(buf
, sizeof(buf
), stdin
)) {
85 for(b
= buf
; *b
&& *b
!= '\n'; ++b
);
91 for(k
= 0; *b
> ' '; ++b
)
108 if (b
- buf
< sizeof(fmt
)) {
128 allow_Quad(case 2: strtopQ(b
,&s
,&q
.x
);)
131 printf("Ignoring \"%s\"\n", s
);
135 printf("d.x = %.g = #%x %x; %s ==> ", d
.x
, d
.u
[1], d
.u
[0], fmt
);
140 printf("x.x = %.Lg = #%x %x %x %x; %s ==> ", x
.x
,
141 x
.u
[0], x
.u
[1], x
.u
[2], x
.u
[3], fmt
);
143 printf("x.x = %.Lg = #%x %x %x %x %x; %s ==> ", x
.x
,
144 x
.u
[4], x
.u
[3], x
.u
[2], x
.u
[1], x
.u
[0], fmt
);
150 printf("q.x = %.Lqg = #%x %x %x %x; %s ==> ", q
.x
,
151 q
.u
[3], q
.u
[2], q
.u
[1], q
.u
[0], fmt
);