1 /*
2 * Mathlib - A Mathematical Function Library
3 * Copyright (C) 1998 Ross Ihaka
4 * Copyright (C) 2000-7 The R Core Team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, a copy is available at
18 * http://www.r-project.org/Licenses/
19 */
20
21 #include "nmath.h"
22 #include <limits.h>
23
Rf_i1mach(int i)24 attribute_hidden int Rf_i1mach(int i)
25 {
26 switch(i) {
27
28 case 1: return 5;
29 case 2: return 6;
30 case 3: return 0;
31 case 4: return 0;
32
33 case 5: return CHAR_BIT * sizeof(int);
34 case 6: return sizeof(int)/sizeof(char);
35
36 case 7: return 2;
37 case 8: return CHAR_BIT * sizeof(int) - 1;
38 case 9: return INT_MAX;
39
40 case 10: return FLT_RADIX;
41
42 case 11: return FLT_MANT_DIG;
43 case 12: return FLT_MIN_EXP;
44 case 13: return FLT_MAX_EXP;
45
46 case 14: return DBL_MANT_DIG;
47 case 15: return DBL_MIN_EXP;
48 case 16: return DBL_MAX_EXP;
49
50 default: return 0;
51 }
52 }
53
F77_NAME(i1mach)54 int F77_NAME(i1mach)(int *i)
55 {
56 return Rf_i1mach(*i);
57 }
58