Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
qnan.c File Reference
#include "arith.h"
#include <stdio.h>
Include dependency graph for qnan.c:

Go to the source code of this file.

Macros

#define Long   long
 
#define UL   (unsigned long)
 

Typedefs

typedef unsigned Long Ulong
 

Functions

int main (void)
 

Macro Definition Documentation

◆ Long

#define Long   long

Definition at line 49 of file qnan.c.

◆ UL

#define UL   (unsigned long)

Definition at line 66 of file qnan.c.

Typedef Documentation

◆ Ulong

typedef unsigned Long Ulong

Definition at line 52 of file qnan.c.

Function Documentation

◆ main()

int main ( void  )

Definition at line 68 of file qnan.c.

69 {
70 #ifdef HAVE_IEEE
71  typedef union
72  {
73  float f;
74  double d;
75  Ulong L[4];
76 #ifndef NO_LONG_LONG
77  unsigned short u[5];
78  long double D;
79 #endif
80  } U;
81  U a, b, c;
82  int i;
83 
84  a.L[0] = b.L[0] = 0x7f800000;
85  c.f = a.f - b.f;
86  printf("#define f_QNAN 0x%lx\n", UL c.L[0]);
87  a.L[_0] = b.L[_0] = 0x7ff00000;
88  a.L[_1] = b.L[_1] = 0;
89  c.d = a.d - b.d; /* quiet NaN */
90  printf("#define d_QNAN0 0x%lx\n", UL c.L[0]);
91  printf("#define d_QNAN1 0x%lx\n", UL c.L[1]);
92 #ifdef NO_LONG_LONG
93  for(i = 0; i < 4; i++)
94  printf("#define ld_QNAN%d 0xffffffff\n", i);
95  for(i = 0; i < 5; i++)
96  printf("#define ldus_QNAN%d 0xffff\n", i);
97 #else
98  b.D = c.D = a.d;
99  if(printf("") < 0)
100  c.D = 37; /* never executed; just defeat optimization */
101  a.L[2] = a.L[3] = 0;
102  a.D = b.D - c.D;
103  for(i = 0; i < 4; i++)
104  printf("#define ld_QNAN%d 0x%lx\n", i, UL a.L[i]);
105  for(i = 0; i < 5; i++)
106  printf("#define ldus_QNAN%d 0x%x\n", i, a.u[i]);
107 #endif
108 #endif /* HAVE_IEEE */
109  return 0;
110 }
#define UL
Definition: qnan.c:66
Definition: gdtoaimp.h:284
double d
Definition: gdtoaimp.h:286
ULong L[2]
Definition: gdtoaimp.h:287
unsigned Long Ulong
Definition: qnan.c:52

References U::d, U::L, and UL.