Arcane  4.2.1.0
User documentation
Loading...
Searching...
No Matches
Math.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/* Math.h (C) 2000-2026 */
9/* */
10/* Diverse mathematical functions. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_MATH_H
13#define ARCANE_UTILS_MATH_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#ifndef ARCCORE_COMPILING_FRAMEWORK
19#include "arcane/utils/Convert.h"
20#endif
21#include "arccore/base/MathBase.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::math
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32/*!
33 * \brief Truncates the precision of the real number v to nb_digit significant figures.
34 *
35 * For a double-precision real number in IEEE 754, the number of significant bits
36 * is 15 or 16 depending on the value. It should be noted that it is not possible
37 * to simply and quickly truncate the precision to a given value.
38 * This is why nb_digit represents an approximate number of digits.
39 * Notably, it is not possible to go below 8 significant figures.
40 *
41 * If nb_digit is less than or equal to zero or greater than 15, the value v is returned.
42 */
43extern ARCANE_UTILS_EXPORT double
44truncateDouble(double v, Integer nb_digit);
45
46/*---------------------------------------------------------------------------*/
47/*---------------------------------------------------------------------------*/
48
49/*!
50 * \brief Truncates the precision of the array of real numbers values to
51 * \a nb_digit significant figures.
52 *
53 * On exit, each element of values is modified as if after calling
54 * truncateDouble(double v,Integer nb_digit).
55 */
56extern ARCANE_UTILS_EXPORT void
57truncateDouble(ArrayView<double> values, Integer nb_digit);
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62} // End namespace Arcane::math
63
64/*---------------------------------------------------------------------------*/
65/*---------------------------------------------------------------------------*/
66
67#ifdef ARCANE_REAL_USE_APFLOAT
68#include "arcane/utils/MathApfloat.h"
69#endif
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
74#endif
Declarations of types used in Arcane.
Namespace for mathematical functions.
Definition MathUtils.h:36
double truncateDouble(double v, Integer nb_digit)
Truncates the precision of the real number v to nb_digit significant figures.
Definition Math.cc:81
Int32 Integer
Type representing an integer.