-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provides decorator to handle rounded arithmetic
- Loading branch information
Showing
42 changed files
with
613 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <cfenv> | ||
#include <eve/module/core/decorator/core.hpp> | ||
|
||
namespace eve::detail | ||
{ | ||
|
||
template < typename O, typename F, typename T, std::same_as<T> ... Ts> | ||
EVE_FORCEINLINE constexpr T with_rounding(F f, T a, Ts ... b) noexcept | ||
{ | ||
#ifdef SPY_COMPILER_IS_MSVC | ||
#pragma float_control(precise, on, push) | ||
#endif | ||
#ifdef SPY_COMPILER_IS_CLANG | ||
#pragma clang fp exceptions(strict) | ||
#endif | ||
#ifdef SPY_COMPILER_IS_GCC | ||
#if __GNUC__ >= 13 | ||
#pragma STDC FENV_ACCESS on | ||
#endif | ||
#endif | ||
auto oldstate = std::fegetround(); | ||
std::fesetround(rounding_control<O>()); | ||
auto r = f(a, b...); | ||
std::fesetround(oldstate); | ||
#ifdef SPY_COMPILER_IS_GCC | ||
#if __GNUC__ >= 13 | ||
#pragma STDC FENV_ACCESS off | ||
#endif | ||
#endif | ||
#ifdef SPY_COMPILER_IS_MSVC | ||
#pragma float_control(pop) | ||
#endif | ||
return r; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.