File: check_float.c

package info (click to toggle)
grace 1%3A5.1.25-18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,828 kB
  • sloc: ansic: 102,045; sh: 5,492; makefile: 572; fortran: 56; perl: 56
file content (45 lines) | stat: -rw-r--r-- 1,049 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* check_float.c -- Rolf Niepraschk 11/97, niepraschk@ptb.de */
/* test program for the cephes library definitions */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define LOG2EA 0.44269504088896340735992
#define EQS(x, y) (strcmp(x, y) == 0)
#define ACCURACY "%1.4f"

typedef struct
{
  union {unsigned short s[5]; double d;} f;
  char *name;  
} XTYPE;

XTYPE X[] = { {{0037742,0124354,0122560,0057703}, "DEC"}, 
              {{0x0bf8,0x94ae,0x551d,0x3fdc}, "IBMPC"},
	      {{0x3fdc,0x551d,0x94ae,0x0bf8}, "MIEEE"},
	      {{0,0,0,0}, "UNK"},
	      {{0,0,0,0}, ""} 
	    };
	    
int main (int argc, char *argv[])
{
  int i; char TMPSTR[1024]; char LOG2EA_STR[80];
  i = 0;
  
  sprintf(LOG2EA_STR, ACCURACY, LOG2EA);
  
  for (i=0; *X[i].name; i++) 
  {
    sprintf(TMPSTR, ACCURACY, X[i].f.d);
    if (EQS(TMPSTR, LOG2EA_STR)) break;
  }
    
  if (*X[i].name) 
     printf("Your system needs \"#define %s = 1\"\n", X[i].name);
  else
     printf("Try to use \"#define %s = 1\"\n", X[--i].name); 
  
  
  exit(EXIT_SUCCESS);
}