PLaSK library
Loading...
Searching...
No Matches
mach.c
Go to the documentation of this file.
1#include <stdlib.h>
2#include <stdio.h>
3#include <float.h>
4#include <limits.h>
5#include <math.h>
6
7#ifndef DBL_EPSILON
8# define DBL_EPSILON 2.2204460492503131e-16
9#endif
10
11/* C source for I1MACH */
12/* Note that some values may need changing. */
13long i1mach(long *i)
14{
15 switch(*i){
16 case 1: return 5; /* standard input */
17 case 2: return 6; /* standard output */
18 case 3: return 7; /* standard punch */
19 case 4: return 0; /* standard error */
20 case 5: return 32; /* bits per long */
21 case 6: return sizeof(int);
22 case 7: return 2; /* base for longs */
23 case 8: return 31; /* digits of long base */
24 case 9: return LONG_MAX;
25 case 10: return FLT_RADIX;
26 case 11: return FLT_MANT_DIG;
27 case 12: return FLT_MIN_EXP;
28 case 13: return FLT_MAX_EXP;
29 case 14: return DBL_MANT_DIG;
30 case 15: return DBL_MIN_EXP;
31 case 16: return DBL_MAX_EXP;
32 }
33 fprintf(stderr, "invalid argument: i1mach(%ld)\n", *i);
34 exit(1);return 0; /* some compilers demand return values */
35}
36
37/* Standard C source for D1MACH */
38double d1mach(long *i)
39{
40 switch(*i){
41 case 1: return DBL_MIN;
42 case 2: return DBL_MAX;
43 case 3: return DBL_EPSILON/FLT_RADIX;
44 case 4: return DBL_EPSILON;
45 case 5: return log10((double)FLT_RADIX);
46 }
47 fprintf(stderr, "invalid argument: d1mach(%ld)\n", *i);
48 exit(1); return 0.; /* some compilers demand return values */
49}
50