MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / round

Function round

extern/boost/boost/chrono/round.hpp:27–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 */
26 template <class To, class Rep, class Period>
27 To round(const duration<Rep, Period>& d)
28 {
29 typedef typename common_type<To, duration<Rep, Period> >::type result_type;
30 result_type diff0;
31 result_type diff1;
32
33 To t0 = duration_cast<To>(d);
34 To t1 = t0;
35 if (t0>d) {
36 --t1;
37 diff0 = t0 - d;
38 diff1 = d - t1;
39 } else {
40 ++t1;
41 diff0 = d - t0;
42 diff1 = t1 - d;
43 }
44
45 if (diff0 == diff1)
46 {
47 if (t0.count() & 1)
48 return t1;
49 return t0;
50 }
51 else if (diff0 < diff1)
52 return t0;
53 return t1;
54 }
55
56 } // namespace chrono
57} // namespace boost

Callers 5

result_type roundMethod · 0.50
iroundFunction · 0.50
lroundFunction · 0.50
llroundFunction · 0.50
normalize_valueFunction · 0.50

Calls 1

countMethod · 0.45

Tested by

no test coverage detected