1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

fix math functions

This commit is contained in:
bolero-MURAKAMI 2013-02-14 18:02:43 +09:00
parent 5d809ef5c9
commit fa1d769bdf
76 changed files with 582 additions and 169 deletions

View file

@ -1,7 +1,7 @@
#ifndef SPROUT_MATH_REM_QUO_HPP
#define SPROUT_MATH_REM_QUO_HPP
#include <cstdint>
#include <limits>
#include <type_traits>
#include <stdexcept>
#include <sprout/config.hpp>
@ -17,7 +17,13 @@ namespace sprout {
template<typename R, typename T>
inline SPROUT_CONSTEXPR sprout::pair<T, R>
rem_quo_impl(T x, T y, R quo) {
return sprout::pair<T, T>(x - quo * y, quo);
typedef sprout::pair<T, R> type;
return x == std::numeric_limits<T>::infinity() || x == -std::numeric_limits<T>::infinity() || y == 0
? type(std::numeric_limits<T>::quiet_NaN(), quo)
: x == 0 ? type(T(0), quo)
: y == std::numeric_limits<T>::infinity() || y == -std::numeric_limits<T>::infinity() ? type(x, quo)
: type(x - quo * y, quo)
;
}
template<
typename R = int,