mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
add sprout/rational.hpp
add sprout/math/common_factor.hpp
This commit is contained in:
parent
dc8cb3d14e
commit
5a9b2e4f7d
8 changed files with 1153 additions and 119 deletions
|
@ -1,7 +1,9 @@
|
|||
#ifndef SPROUT_CSTDLIB_ABS_HPP
|
||||
#define SPROUT_CSTDLIB_ABS_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/enabler_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
@ -26,6 +28,25 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR long long abs(long long j) {
|
||||
return sprout::llabs(j);
|
||||
}
|
||||
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<
|
||||
std::is_integral<IntType>::value && std::is_signed<IntType>::value
|
||||
>::type = sprout::enabler
|
||||
>
|
||||
SPROUT_CONSTEXPR IntType abs(IntType j) {
|
||||
return j < 0 ? -j : j;
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<
|
||||
std::is_integral<IntType>::value && std::is_unsigned<IntType>::value
|
||||
>::type = sprout::enabler
|
||||
>
|
||||
SPROUT_CONSTEXPR IntType abs(IntType j) {
|
||||
return j;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CSTDLIB_ABS_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue