mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
fix math functions
This commit is contained in:
parent
5d809ef5c9
commit
fa1d769bdf
76 changed files with 582 additions and 169 deletions
|
@ -1,7 +1,7 @@
|
|||
#ifndef SPROUT_MATH_FMOD_HPP
|
||||
#define SPROUT_MATH_FMOD_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <stdexcept>
|
||||
#include <sprout/config.hpp>
|
||||
|
@ -18,7 +18,10 @@ namespace sprout {
|
|||
>
|
||||
inline SPROUT_CONSTEXPR FloatType
|
||||
fmod(FloatType x, FloatType y) {
|
||||
return y == 0 ? throw std::domain_error("fmod: divide by zero.")
|
||||
return x == std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity() || y == 0
|
||||
? std::numeric_limits<FloatType>::quiet_NaN()
|
||||
: x == 0 ? FloatType(0)
|
||||
: y == std::numeric_limits<FloatType>::infinity() || y == -std::numeric_limits<FloatType>::infinity() ? x
|
||||
: x - sprout::math::trunc(x / y) * y
|
||||
;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue