This source file includes following definitions.
- main
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 #include <config.h>
  20 
  21 #include <ieee754.h>
  22 #include <stdio.h>
  23 
  24 static struct {
  25   float x;
  26   unsigned sign; unsigned exponent; unsigned frac;
  27 } const float_tests[] =
  28   {
  29    {0, 0, 0, 0},
  30    {-0.0, 1, 0, 0},
  31    {0.1, 0, 0x7b, 0x4ccccd}
  32   };
  33 
  34 static struct {
  35   double x;
  36   unsigned sign; unsigned exponent; unsigned frac_hi; unsigned frac_lo;
  37 } const double_tests[] =
  38   {
  39    {0, 0, 0, 0},
  40    {-0.0, 1, 0, 0 },
  41    {0.1, 0, 0x3fb, 0x99999, 0x9999999a}
  42   };
  43 
  44 int
  45 main (void)
     
  46 {
  47   int i;
  48 
  49   for (i = 0; i < sizeof float_tests / sizeof *float_tests; i++)
  50     {
  51       union ieee754_float u;
  52       u.f = float_tests[i].x;
  53       if (float_tests[i].sign != u.ieee.negative)
  54         return 1;
  55       if (float_tests[i].exponent != u.ieee.exponent)
  56         return 2;
  57       if (float_tests[i].frac != u.ieee.mantissa)
  58         return 3;
  59     }
  60 
  61   for (i = 0; i < sizeof double_tests / sizeof *double_tests; i++)
  62     {
  63       union ieee754_double u;
  64       u.d = double_tests[i].x;
  65       if (double_tests[i].sign != u.ieee.negative)
  66         return 4;
  67       if (double_tests[i].exponent != u.ieee.exponent)
  68         return 5;
  69       if (double_tests[i].frac_hi != u.ieee.mantissa0)
  70         return 6;
  71       if (double_tests[i].frac_lo != u.ieee.mantissa1)
  72         return 7;
  73     }
  74 
  75   return 0;
  76 }