micro-test-plus
4.1.0
µTest++ Testing Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1
/*
2
* This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
* Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
*
5
* Permission to use, copy, modify, and/or distribute this software for any
6
* purpose is hereby granted, under the terms of the MIT license.
7
*
8
* If a copy of the license was not distributed with this file, it can be
9
* obtained from https://opensource.org/licenses/mit.
10
*
11
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
* released under the terms of the Boost Version 1.0 Software License,
13
* which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14
*/
15
16
// ----------------------------------------------------------------------------
17
48
49
#ifndef MICRO_TEST_PLUS_MATH_H_
50
#define MICRO_TEST_PLUS_MATH_H_
51
52
// ----------------------------------------------------------------------------
53
54
#ifdef __cplusplus
55
56
// ----------------------------------------------------------------------------
57
58
#include <array>
59
60
// ----------------------------------------------------------------------------
61
62
#if defined(__GNUC__)
63
#pragma GCC diagnostic push
64
#pragma GCC diagnostic ignored "-Wconversion"
65
#if defined(__clang__)
66
#pragma clang diagnostic ignored "-Wc++98-compat"
67
#pragma clang diagnostic ignored "-Wc++20-compat"
68
#endif
69
#endif
70
71
// ============================================================================
72
73
namespace
micro_os_plus::micro_test_plus
74
{
75
// --------------------------------------------------------------------------
76
96
namespace
math
97
{
107
template
<
class
T>
108
[[nodiscard]]
constexpr
auto
109
abs
(
const
T t)
noexcept
-> T;
110
121
template
<
class
T>
122
[[nodiscard]]
constexpr
auto
123
min_value
(
const
T& lhs,
const
T& rhs)
noexcept
->
const
T&;
124
138
template
<
class
T,
class
Exp_T>
139
[[nodiscard]]
constexpr
auto
140
pow
(
const
T base,
const
Exp_T exp)
noexcept
-> T;
141
153
template
<
class
T,
char
... Cs>
154
[[nodiscard]]
consteval
auto
155
num
(
void
) -> T;
156
168
template
<
class
T,
char
... Cs>
169
[[nodiscard]]
consteval
auto
170
den
(
void
) -> T;
171
183
template
<
class
T,
char
... Cs>
184
[[nodiscard]]
consteval
auto
185
den_size
(
void
) -> T;
186
198
template
<
class
T,
class
Value_T>
199
[[nodiscard]]
constexpr
auto
200
den_size
(Value_T value) -> T;
201
202
// ------------------------------------------------------------------------
203
}
// namespace math
204
205
// --------------------------------------------------------------------------
206
}
// namespace micro_os_plus::micro_test_plus
207
208
#if defined(__GNUC__)
209
#pragma GCC diagnostic pop
210
#endif
211
212
// ----------------------------------------------------------------------------
213
214
#endif
// __cplusplus
215
216
// ============================================================================
217
// Templates & constexpr implementations.
218
219
#include "
inlines/math-inlines.h
"
220
221
// ----------------------------------------------------------------------------
222
223
#endif
// MICRO_TEST_PLUS_MATH_H_
224
225
// ----------------------------------------------------------------------------
math-inlines.h
C++ header file with inline implementations for the µTest++ mathematical utilities.
micro_os_plus::micro_test_plus::math
Mathematical utilities for the µTest++ testing framework.
Definition
math-inlines.h:78
micro_os_plus::micro_test_plus::math::min_value
constexpr auto min_value(const T &lhs, const T &rhs) noexcept -> const T &
Computes the minimum of two comparable values.
Definition
math-inlines.h:118
micro_os_plus::micro_test_plus::math::pow
constexpr auto pow(const T base, const Exp_T exp) noexcept -> T
Generic exponentiation function to compute the power of a base raised to an exponent.
Definition
math-inlines.h:139
micro_os_plus::micro_test_plus::math::den
consteval auto den(void) -> T
Computes the decimal part of a number represented as an array of characters.
Definition
math-inlines.h:203
micro_os_plus::micro_test_plus::math::abs
constexpr auto abs(const T t) noexcept -> T
Computes the absolute value of a given comparable value.
Definition
math-inlines.h:97
micro_os_plus::micro_test_plus::math::den_size
consteval auto den_size(void) -> T
Computes the number of decimal places in a number represented as an array of characters.
Definition
math-inlines.h:238
micro_os_plus::micro_test_plus::math::num
consteval auto num(void) -> T
Computes the integral value of a number represented as an array of characters.
Definition
math-inlines.h:163
micro_os_plus::micro_test_plus
Primary namespace for the µTest++ testing framework.
include
micro-os-plus
micro-test-plus
math.h
Generated by
1.17.0