Heidelberg Educational Numerics Library
Version 0.27 (from 15 March 2021)
src
precision.hh
Go to the documentation of this file.
1
// -*- tab-width: 4; indent-tabs-mode: nil -*-
2
#ifndef HDNUM_PRECISION_HH
3
#define HDNUM_PRECISION_HH
4
9
namespace
hdnum {
10
11
// find largest eps such that 0.5 + eps > 0.5
12
template
<
typename
X>
13
int
precision (X& eps)
14
{
15
X x,large,largex,two;
16
large = 0.5;
17
two = 2.0;
18
x = 0.5;
19
largex = large+x;
20
int
i(0);
21
while
(largex>large)
22
{
23
eps = x;
24
i = i+1;
25
// std::cout << i << " " << std::scientific << std::showpoint
26
// << std::setprecision(15) << large+x << " " << x << std::endl;
27
x = x/two;
28
largex = large+x;
29
}
30
return
i;
31
}
32
33
}
// namespace hdnum
34
35
#endif
Generated by
1.10.0