/src/r-source/src/nmath/d1mach.c
Line | Count | Source |
1 | | /* |
2 | | * Mathlib - A Mathematical Function Library |
3 | | * Copyright (C) 1998 Ross Ihaka |
4 | | * Copyright (C) 2000-2024 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 | | * https://www.R-project.org/Licenses/ |
19 | | */ |
20 | | |
21 | | /* NaNs propagated correctly */ |
22 | | |
23 | | |
24 | | /*-- FIXME: Eliminate calls to these |
25 | | * ===== o from C code when |
26 | | * o it is only used to initialize "static" variables (threading) |
27 | | * and use the DBL_... constants instead |
28 | | */ |
29 | | |
30 | | #include "nmath.h" |
31 | | |
32 | | attribute_hidden double Rf_d1mach(int i) |
33 | 0 | { |
34 | 0 | switch(i) { |
35 | 0 | case 1: return DBL_MIN; |
36 | 0 | case 2: return DBL_MAX; |
37 | | |
38 | 0 | case 3: /* = FLT_RADIX ^ - DBL_MANT_DIG |
39 | | for IEEE: = 2^-53 = 1.110223e-16 = .5*DBL_EPSILON */ |
40 | 0 | return 0.5*DBL_EPSILON; |
41 | | |
42 | 0 | case 4: /* = FLT_RADIX ^ (1- DBL_MANT_DIG) = |
43 | | for IEEE: = 2^-52 = DBL_EPSILON */ |
44 | 0 | return DBL_EPSILON; |
45 | | |
46 | 0 | case 5: return M_LOG10_2; |
47 | | |
48 | 0 | default: return 0.0; |
49 | 0 | } |
50 | 0 | } |
51 | | |
52 | | #ifdef __cplusplus |
53 | | extern "C" |
54 | | #endif |
55 | | |
56 | | double F77_SUB(d1mach)(int *i) |
57 | 0 | { |
58 | 0 | return Rf_d1mach(*i); |
59 | 0 | } |