mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
add lround, llround
This commit is contained in:
parent
77f058a34c
commit
36fe60bec3
7 changed files with 140 additions and 28 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <stdexcept>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/math/detail/config.hpp>
|
||||
#include <sprout/math/isinf.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -15,8 +16,7 @@ namespace sprout {
|
|||
template<typename FloatType>
|
||||
inline SPROUT_CONSTEXPR FloatType
|
||||
ceil_impl(FloatType x, FloatType x0) {
|
||||
return x - x0 < std::numeric_limits<FloatType>::epsilon()
|
||||
? x0
|
||||
return x - x0 < std::numeric_limits<FloatType>::epsilon() ? x0
|
||||
: x0 + 1
|
||||
;
|
||||
}
|
||||
|
@ -26,11 +26,11 @@ namespace sprout {
|
|||
>
|
||||
inline SPROUT_CONSTEXPR FloatType
|
||||
ceil(FloatType x) {
|
||||
return std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
|
||||
? throw std::domain_error("ceil: Sorry, not implemented.")
|
||||
: x < 0
|
||||
? -static_cast<FloatType>(static_cast<std::uintmax_t>(-x))
|
||||
: sprout::math::detail::ceil_impl(x, static_cast<FloatType>(static_cast<std::uintmax_t>(x)))
|
||||
return sprout::math::isinf(x) ? x
|
||||
: std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
|
||||
? throw std::domain_error("ceil: Sorry, not implemented.")
|
||||
: x < 0 ? -static_cast<FloatType>(static_cast<std::uintmax_t>(-x))
|
||||
: sprout::math::detail::ceil_impl(x, static_cast<FloatType>(static_cast<std::uintmax_t>(x)))
|
||||
;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue