-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(add): support int128 + - * / (#10)
* try to support i128 add * try to adopt int128 & uint128 from abseil-cpp * add int128 add test * add int128 mul test * support int128 div operation
- Loading branch information
Showing
15 changed files
with
1,328 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
add_subdirectory(numbers) | ||
|
||
add_library(numbers_lib STATIC ${ALL_OBJECT_FILES}) | ||
|
||
find_package(Threads REQUIRED) | ||
|
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,39 @@ | ||
#ifndef NUMBERS_BITS_HH | ||
#define NUMBERS_BITS_HH | ||
|
||
#include <type_traits> | ||
|
||
#include "internal/config.h" | ||
#include "internal/bits.hh" | ||
|
||
#if NUMBERS_INTERNAL_CPLUSPLUS_LANG >= 202002L | ||
#include <bit> | ||
#endif | ||
|
||
// check if the compiler supports <bit> header | ||
#if defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L | ||
|
||
using std::countl_one; | ||
using std::countl_zero; | ||
|
||
#else | ||
|
||
// Counting functions | ||
// | ||
// While these functions are typically constexpr, on some platforms, they may | ||
// not be marked as constexpr due to constraints of the compiler/available | ||
// intrinsics. | ||
template <class T> | ||
inline typename std::enable_if<std::is_unsigned_v<T>, int>::type countl_zero(T x) noexcept { | ||
return numbers_internal::count_leading_zeroes(x); | ||
} | ||
|
||
template <class T> | ||
inline typename std::enable_if<std::is_unsigned_v<T>, int>::type countl_one(T x) noexcept { | ||
// Avoid integer promotion to a wider type | ||
return countl_zero(static_cast<T>(~x)); | ||
} | ||
|
||
#endif | ||
|
||
#endif |
Oops, something went wrong.