Arcane  4.2.1.0
Developer documentation
Loading...
Searching...
No Matches
FloatInfo.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* FloatInfo.h (C) 2000-2026 */
9/* */
10/* Informations about limits for floating point types. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_BASE_FLOATINFO_H
13#define ARCCORE_BASE_FLOATINFO_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19#include <cfloat>
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
33template <typename T>
35{
36 public:
37
39 static constexpr bool isFloatType() { return false; }
40};
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
47template <>
48class FloatInfo<float>
49{
50 public:
51
53 static constexpr bool isFloatType() { return true; }
54
55 public:
56
57 static constexpr unsigned int precision() { return 1; }
58 static constexpr unsigned int maxDigit() { return FLT_DIG; }
59 static constexpr float epsilon() { return FLT_EPSILON; }
60 static constexpr float nearlyEpsilon() { return FLT_EPSILON * 10.0f; }
61 static constexpr float maxValue() { return FLT_MAX; }
62 static constexpr float zero() { return 0.0f; }
63};
64
65/*---------------------------------------------------------------------------*/
66/*---------------------------------------------------------------------------*/
70template <>
71class FloatInfo<double>
72{
73 public:
74
76 static constexpr bool isFloatType() { return true; }
77
78 public:
79
80 static constexpr unsigned int precision() { return 2; }
81 static constexpr unsigned int maxDigit() { return DBL_DIG; }
82 static constexpr double epsilon() { return DBL_EPSILON; }
83 static constexpr double nearlyEpsilon() { return DBL_EPSILON * 10.0; }
84 static constexpr double maxValue() { return DBL_MAX; }
85 static constexpr double zero() { return 0.0; }
86};
87
88/*---------------------------------------------------------------------------*/
89/*---------------------------------------------------------------------------*/
94template <>
95class FloatInfo<long double>
96{
97 public:
98
100 static constexpr bool isFloatType() { return true; }
101
102 public:
103
104 static constexpr unsigned int precision() { return 3; }
105 static constexpr unsigned int maxDigit() { return LDBL_DIG; }
106 static constexpr long double epsilon() { return LDBL_EPSILON; }
107 static constexpr long double nearlyEpsilon() { return LDBL_EPSILON * 10.0; }
108 static constexpr long double maxValue() { return LDBL_MAX; }
109 static constexpr long double zero() { return 0.0l; }
110};
111
112#ifdef ARCCORE_REAL_USE_APFLOAT
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
122template <>
123class FloatInfo<apfloat>
124{
125 public:
126
128 //typedef TrueType _IsFloatType;
130 static constexpr bool isFloatType() { return true; }
131
132 public:
133
134 static constexpr unsigned int precision() { return 3; }
135 static constexpr unsigned int maxDigit() { return 35; }
136 static constexpr apfloat epsilon() { return 1e-30; }
137 static constexpr apfloat nearlyEpsilon() { return 1e-28; }
138 static constexpr apfloat maxValue() { return apfloat("1e1000"); }
139 static constexpr apfloat zero() { return apfloat("0.0"); }
140};
141#endif
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
145
146} // End namespace Arcane
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
151#endif
Definitions and globals of Arccore.
static constexpr bool isFloatType()
Indicates that the instantiation is for a floating-point type.
Definition FloatInfo.h:76
static constexpr bool isFloatType()
Indicates that the instantiation is for a floating-point type.
Definition FloatInfo.h:53
static constexpr bool isFloatType()
Indicates that the instantiation is for a floating-point type.
Definition FloatInfo.h:100
Information about the floating-point type.
Definition FloatInfo.h:35
static constexpr bool isFloatType()
Indicates that the instantiation is for a floating-point type.
Definition FloatInfo.h:39
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --