File: d1mach.c

package info (click to toggle)
insighttoolkit 3.20.1%2Bgit20120521-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 80,652 kB
  • sloc: cpp: 458,133; ansic: 196,223; fortran: 28,000; python: 3,839; tcl: 1,811; sh: 1,184; java: 583; makefile: 430; csh: 220; perl: 193; xml: 20
file content (29 lines) | stat: -rw-r--r-- 803 bytes parent folder | download | duplicates (4)
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
/** d1mach - determine machine precision.  Instead of using the
 * original fortran version (or f2c'd version), use this C code
 * instead. This is code is actually in a comment in the original
 * fortran code.
 *
 * Note, that by using this C code, d1mach is now thread safe,
 * whereas, the f2c code was not.
 *
 */
 

/* Standard C source for D1MACH */
#include <stdio.h>
#include <float.h> 
#include <math.h> 
#include "v3p_f2c_original.h"
double d1mach_(integer *i) 
{ 
  switch(*i)
    { 
    case 1: return DBL_MIN; 
    case 2: return DBL_MAX; 
    case 3: return DBL_EPSILON/FLT_RADIX; 
    case 4: return DBL_EPSILON;
    case 5: return log10((double)FLT_RADIX); 
    } 
  fprintf(stderr, "invalid argument: d1mach(%ld)\n", (long) *i);
  return 0; /* some compilers demand return values */
}