TMB Documentation
v1.9.11
TMB
inst
include
tiny_ad
beta
i1mach.cpp
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
* https://www.R-project.org/Licenses/
19
*/
20
21
#include "nmath.h"
22
#include <limits.h>
23
24
template
<
class
T>
25
attribute_hidden
int
Rf_i1mach(T i)
26
{
27
switch
(i) {
28
29
case
1:
return
5;
30
case
2:
return
6;
31
case
3:
return
0;
32
case
4:
return
0;
33
34
case
5:
return
CHAR_BIT *
sizeof
(int);
35
case
6:
return
sizeof
(int)/
sizeof
(
char
);
36
37
case
7:
return
2;
38
case
8:
return
CHAR_BIT *
sizeof
(int) - 1;
39
case
9:
return
INT_MAX;
40
41
case
10:
return
FLT_RADIX;
42
43
case
11:
return
FLT_MANT_DIG;
44
case
12:
return
FLT_MIN_EXP;
45
case
13:
return
FLT_MAX_EXP;
46
47
case
14:
return
DBL_MANT_DIG;
48
case
15:
return
DBL_MIN_EXP;
49
case
16:
return
DBL_MAX_EXP;
50
51
default
:
return
0;
52
}
53
}
License:
GPL v2