CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
LargeInteger.hpp File Reference
#include "CeresEngine/DataTypes.hpp"
#include "CeresEngine/Macros.hpp"
#include "CeresEngine/Foundation/Hash.hpp"
#include <cmath>
#include <cstdint>
#include <limits>
#include <type_traits>

Go to the source code of this file.

Classes

struct  Math::LargeInteger< Hi, Low >
 A wide integer type that uses Hi for the high-order bits in the integer data and Lo for the low-order bits. More...
 
struct  Math::LargeIntegerCLZHelper< LargeInteger< High, Low > >
 

Namespaces

namespace  Math
 
namespace  Math::literals
 
namespace  Math::literals::impl_
 

Typedefs

using Math::Int128 = LargeInteger< Int64 >
 An alias to a signed 128-bit integer type.
 
using Math::UInt128 = LargeInteger< UInt64 >
 An alias to a unsigned 128-bit integer type.
 

Functions

template<typename T >
constexpr void Math::multwide (T a, T b, T &hi, T &lo)
 
template<typename T >
constexpr void Math::multwide (LargeInteger< T, T > a, LargeInteger< T, T > b, LargeInteger< T, T > &hi, LargeInteger< T, T > &lo)
 
template<typename T >
constexpr void Math::mult128 (T N, T M, T &Ans)
 
template<typename U >
constexpr void Math::mult128to256 (U N, U M, U &H, U &L)
 
template<char... _Args>
constexpr UInt128 Math::literals::operator""_u128 ()
 
template<char... _Args>
constexpr Int128 Math::literals::operator""_i128 ()
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator+ (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Add two large integer numbers lhs and rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator- (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Subtracts two large integer numbers lhs and rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator* (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Multiplies two large integer numbers lhs and rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator/ (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Divides two large integer numbers lhs and rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator% (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Calculates the module two large integer numbers lhs and rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator& (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Bitwise and a large integer rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator| (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Bitwise or a large integer rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator^ (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Bitwise xor a large integer rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator<< (LargeInteger< Hi, Low > lhs, int rhs) noexcept
 Left shifts rhs bits from lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator>> (LargeInteger< Hi, Low > lhs, int rhs) noexcept
 Right shifts rhs bits from lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator+ (LargeInteger< Hi, Low > lhs) noexcept
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator- (LargeInteger< Hi, Low > lhs) noexcept
 Inverts the signal of a large integer rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::operator~ (LargeInteger< Hi, Low > lhs) noexcept
 Bitwise negates a large integer rhs.
 
template<typename Hi , typename Low >
constexpr bool Math::operator! (LargeInteger< Hi, Low > lhs) noexcept
 Logically negates a large integer rhs.
 
template<typename Hi , typename Low >
LargeInteger< Hi, Low > & Math::operator++ (LargeInteger< Hi, Low > &lhs) noexcept
 Increments a large integer lhs by 1.
 
template<typename Hi , typename Low >
LargeInteger< Hi, Low > Math::operator++ (LargeInteger< Hi, Low > &lhs, int) noexcept
 Increments a large integer lhs by 1.
 
template<typename Hi , typename Low >
LargeInteger< Hi, Low > & Math::operator-- (LargeInteger< Hi, Low > &lhs) noexcept
 Decrements a large integer lhs by 1.
 
template<typename Hi , typename Low >
LargeInteger< Hi, Low > Math::operator-- (LargeInteger< Hi, Low > &lhs, int) noexcept
 Decrements a large integer lhs by 1.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator+= (LargeInteger< Hi, Low > &lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Add two large integer numbers lhs and rhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator-= (LargeInteger< Hi, Low > &lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Subtract two large integer numbers lhs and rhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator*= (LargeInteger< Hi, Low > &lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Multiply two large integer numbers lhs and rhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator/= (LargeInteger< Hi, Low > &lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Divide two large integer numbers lhs and rhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator%= (LargeInteger< Hi, Low > &lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Calculates the remainder of the division of two large integer numbers lhs and rhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator<<= (LargeInteger< Hi, Low > &lhs, int rhs) noexcept
 Left shifts rhs bits from lhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator>>= (LargeInteger< Hi, Low > &lhs, int rhs) noexcept
 Right shifts rhs bits from lhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator&= (LargeInteger< Hi, Low > &lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Bitwise and a large integer rhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator|= (LargeInteger< Hi, Low > &lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Bitwise or a large integer rhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > & Math::operator^= (LargeInteger< Hi, Low > &lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Bitwise xor a large integer rhs in-place in lhs.
 
template<typename Hi , typename Low >
constexpr bool Math::operator== (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Compares two large integer numbers lhs and rhs for equality.
 
template<typename Hi , typename Low >
constexpr bool Math::operator!= (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Compares two large integer numbers lhs and rhs for inequality.
 
template<typename Hi , typename Low >
constexpr bool Math::operator< (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Compares two large integer numbers lhs and rhs.
 
template<typename Hi , typename Low >
constexpr bool Math::operator<= (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Compares two large integer numbers lhs and rhs.
 
template<typename Hi , typename Low >
constexpr bool Math::operator> (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Compares two large integer numbers lhs and rhs.
 
template<typename Hi , typename Low >
constexpr bool Math::operator>= (LargeInteger< Hi, Low > lhs, typename LargeInteger< Hi, Low >::Self rhs) noexcept
 Compares two large integer numbers lhs and rhs.
 
template<typename Hi , typename Low >
constexpr LargeInteger< Hi, Low > Math::abs (LargeInteger< Hi, Low > x)
 Returns the absolute value of x: |x|.