FireSTARR
Loading...
Searching...
No Matches
LogValue.h
1/* SPDX-License-Identifier: AGPL-3.0-or-later */
2#ifndef FS_LOG_VALUE_H
3#define FS_LOG_VALUE_H
4#include <compare>
5#include "unstable.h"
6namespace fs
7{
12{
13 MathSize value{0};
14 auto operator<=>(const LogValue& rhs) const = default;
15};
16static constexpr LogValue LOG_0_70{-0.35667494393873245};
17static constexpr LogValue LOG_0_75{-0.2876820724517809};
18static constexpr LogValue LOG_0_80{-0.2231435513142097};
19static constexpr LogValue LOG_0_85{-0.16251892949777494};
20static constexpr LogValue LOG_0_90{-0.10536051565782628};
21static constexpr LogValue LOG_1_00{0.0};
22#ifndef _WIN32
23#if __cpp_lib_constexpr_cmath >= 202202L // C++23
24// windows won't use constexpr with log but we can double check numbers are right when compiling
25// elsewhere
26static constexpr LogValue LOG_0_70_CALC{log(0.7)};
27static constexpr LogValue LOG_0_75_CALC{log(0.75)};
28static constexpr LogValue LOG_0_80_CALC{log(0.8)};
29static constexpr LogValue LOG_0_85_CALC{log(0.85)};
30static constexpr LogValue LOG_0_90_CALC{log(0.9)};
31static constexpr LogValue LOG_1_00_CALC{log(1.0)};
32static_assert(abs((LOG_0_70.value - LOG_0_70_CALC.value)) < numeric_limits<MathSize>::epsilon());
33static_assert(abs((LOG_0_75.value - LOG_0_75_CALC.value)) < numeric_limits<MathSize>::epsilon());
34static_assert(abs((LOG_0_80.value - LOG_0_80_CALC.value)) < numeric_limits<MathSize>::epsilon());
35static_assert(abs((LOG_0_90.value - LOG_0_90_CALC.value)) < numeric_limits<MathSize>::epsilon());
36static_assert(abs((LOG_1_00.value - LOG_1_00_CALC.value)) < numeric_limits<MathSize>::epsilon());
37#endif
38#endif
39}
40#endif
A result of calling log(x) for some value of x, pre-calculated at compile time.
Definition LogValue.h:12