4#define _USE_MATH_DEFINES
7#include <corecrt_math_defines.h>
8#include "CoreMinimal.h"
9#include "UObject/NoExportTypes.h"
11#include "BigInteger.generated.h"
157 FBigInteger(
const TArray<uint8>& magnitude,
bool isNegative);
173 FBigInteger(
const TArray<uint32>& magnitude,
bool isNegative);
256 static uint32 Remainder(
const FBigInteger& lhs,
const uint32 rhs);
267 static uint64 Remainder(
const FBigInteger& lhs,
const uint64 rhs);
533 static int32 CountPrecisionBits(
const FBigInteger& value);
569 static int32 Compare(int32 lhs,
const FBigInteger& rhs);
580 static int32 Compare(uint32 lhs,
const FBigInteger& rhs);
591 static int32 Compare(int64 lhs,
const FBigInteger& rhs);
602 static int32 Compare(uint64 lhs,
const FBigInteger& rhs);
613 static int32 Compare(
const FBigInteger& lhs, int32 rhs);
624 static int32 Compare(
const FBigInteger& lhs, uint32 rhs);
635 static int32 Compare(
const FBigInteger& lhs, int64 rhs);
646 static int32 Compare(
const FBigInteger& lhs, uint64 rhs);
676 static uint32 FloorLog10(
const FBigInteger& value);
744 static float LogX(
float base,
const FBigInteger& value);
754 static double LogX(
double base,
const FBigInteger& value);
763 static FBigInteger Pow(int32 base, int32 exponent);
798 static uint32 Gcd(
const FBigInteger& lhs, uint32 rhs);
807 static uint64 Gcd(
const FBigInteger& lhs, uint64 rhs);
874 uint32 Remainder(uint32 rhs)
const;
884 uint64 Remainder(uint64 rhs)
const;
1010 FBigInteger SetWord(int32 index, uint32 word)
const;
1081 int32 CountPrecisionBits()
const;
1128 int32 GetSign()
const;
1142 int32 GetSignedByteLength()
const;
1149 int32 GetSignedWordLength()
const;
1157 int32 GetLength()
const;
1165 int32 GetBit(int32 position)
const;
1173 uint32 GetUpperWord()
const;
1181 uint32 GetWord(int32 index)
const;
1210 float Log10()
const;
1220 double Log10D()
const;
1234 double Log2D()
const;
1248 double LogeD()
const;
1304 bool CanFitIntoUInt()
const;
1325 bool CanFitIntoFloat()
const;
1332 bool CanFitIntoFloatLossy()
const;
1339 bool CanFitIntoDouble()
const;
1346 bool CanFitIntoDoubleLossy()
const;
1353 bool IsEven()
const;
1360 bool IsMinusOne()
const;
1367 bool IsNegative()
const;
1388 bool IsPositive()
const;
1395 bool IsPowerOfTwo()
const;
1402 bool IsZero()
const;
1543 friend uint32 operator%(
FBigInteger lhs,
const uint32 rhs);
1554 friend uint64 operator%(
FBigInteger lhs,
const uint64 rhs);
1633 bool operator!()
const;
1780 void operator=(
bool from);
1788 void operator=(int8 from);
1796 void operator=(uint8 from);
1804 void operator=(int16 from);
1812 void operator=(uint16 from);
1819 void operator=(int32 from);
1826 void operator=(uint32 from);
1833 void operator=(int64 from);
1840 void operator=(uint64 from);
1847 void operator=(
float from);
1854 void operator=(
double from);
1862 explicit operator bool()
const;
1870 explicit operator int8()
const;
1878 explicit operator uint8()
const;
1886 explicit operator int16()
const;
1894 explicit operator uint16()
const;
1902 explicit operator int32()
const;
1910 explicit operator uint32()
const;
1918 explicit operator int64()
const;
1926 explicit operator uint64()
const;
1934 explicit operator float()
const;
1942 explicit operator double()
const;
1949 explicit operator TArray<uint8>()
const;
1956 explicit operator TArray<uint32>()
const;
1958#pragma region OperatorEq
1967 friend bool operator==(int32 lhs,
const FBigInteger& rhs);
1976 friend bool operator==(uint32 lhs,
const FBigInteger& rhs);
1985 friend bool operator==(int64 lhs,
const FBigInteger& rhs);
1994 friend bool operator==(uint64 lhs,
const FBigInteger& rhs);
2003 friend bool operator==(
const FBigInteger& lhs, int32 rhs);
2012 friend bool operator==(
const FBigInteger& lhs, uint32 rhs);
2021 friend bool operator==(
const FBigInteger& lhs, int64 rhs);
2030 friend bool operator==(
const FBigInteger& lhs, uint64 rhs);
2042#pragma region OperatorNeq
2051 friend bool operator!=(int32 lhs,
const FBigInteger& rhs);
2060 friend bool operator!=(uint32 lhs,
const FBigInteger& rhs);
2069 friend bool operator!=(int64 lhs,
const FBigInteger& rhs);
2078 friend bool operator!=(uint64 lhs,
const FBigInteger& rhs);
2087 friend bool operator!=(
const FBigInteger& lhs, int32 rhs);
2096 friend bool operator!=(
const FBigInteger& lhs, uint32 rhs);
2105 friend bool operator!=(
const FBigInteger& lhs, int64 rhs);
2114 friend bool operator!=(
const FBigInteger& lhs, uint64 rhs);
2126#pragma region OperatorLt
2135 friend bool operator<(int32 lhs,
const FBigInteger& rhs);
2144 friend bool operator<(uint32 lhs,
const FBigInteger& rhs);
2153 friend bool operator<(int64 lhs,
const FBigInteger& rhs);
2162 friend bool operator<(uint64 lhs,
const FBigInteger& rhs);
2171 friend bool operator<(
const FBigInteger& lhs,
const int32 rhs);
2180 friend bool operator<(
const FBigInteger& lhs,
const uint32 rhs);
2189 friend bool operator<(
const FBigInteger& lhs,
const int64 rhs);
2198 friend bool operator<(
const FBigInteger& lhs,
const uint64 rhs);
2210#pragma region OperatorGt
2219 friend bool operator>(int32 lhs,
const FBigInteger& rhs);
2228 friend bool operator>(uint32 lhs,
const FBigInteger& rhs);
2237 friend bool operator>(int64 lhs,
const FBigInteger& rhs);
2246 friend bool operator>(uint64 lhs,
const FBigInteger& rhs);
2255 friend bool operator>(
const FBigInteger& lhs, int32 rhs);
2264 friend bool operator>(
const FBigInteger& lhs, uint32 rhs);
2273 friend bool operator>(
const FBigInteger& lhs, int64 rhs);
2282 friend bool operator>(
const FBigInteger& lhs, uint64 rhs);
2294#pragma region OperatorLteq
2303 friend bool operator<=(int32 lhs,
const FBigInteger& rhs);
2312 friend bool operator<=(uint32 lhs,
const FBigInteger& rhs);
2321 friend bool operator<=(int64 lhs,
const FBigInteger& rhs);
2330 friend bool operator<=(uint64 lhs,
const FBigInteger& rhs);
2339 friend bool operator<=(
const FBigInteger& lhs, int32 rhs);
2348 friend bool operator<=(
const FBigInteger& lhs, uint32 rhs);
2357 friend bool operator<=(
const FBigInteger& lhs, int64 rhs);
2366 friend bool operator<=(
const FBigInteger& lhs, uint64 rhs);
2378#pragma region OperatorGteq
2387 friend bool operator>=(int32 lhs,
const FBigInteger& rhs);
2396 friend bool operator>=(uint32 lhs,
const FBigInteger& rhs);
2405 friend bool operator>=(int64 lhs,
const FBigInteger& rhs);
2414 friend bool operator>=(uint64 lhs,
const FBigInteger& rhs);
2423 friend bool operator>=(
const FBigInteger& lhs, int32 rhs);
2432 friend bool operator>=(
const FBigInteger& lhs, uint32 rhs);
2441 friend bool operator>=(
const FBigInteger& lhs, int64 rhs);
2450 friend bool operator>=(
const FBigInteger& lhs, uint64 rhs);
2468 void SetValueIn(
bool value);
2475 void SetValueIn(int8 value);
2482 void SetValueIn(uint8 value);
2489 void SetValueIn(int16 value);
2496 void SetValueIn(uint16 value);
2562 void SetValueIn(
const TArray<uint8>& magnitude,
bool isNegative);
2579 void SetValueIn(
const TArray<uint32>& magnitude,
bool isNegative);
2706 void SetSignIn(
bool isNegative);
2762 void SelectIn(
const FBigInteger& rhs,
bool condition);
2781 void SetValueIn(
const TArray<uint32>& magnitude, int32 sign);
2784 static uint32 AddCarry(uint32* u1, uint32 u2, uint32 uCarry);
2785 static uint32 AddCarry(uint32* u1, uint32 uCarry);
2787 void SubtractCore(
const FBigInteger& V, int32 length);
2788 static uint32 SubBorrow(uint32* u1, uint32 u2, uint32 uBorrow);
2789 static uint32 SubBorrow(uint32* u1, uint32 uBorrow);
2791 static bool DivideGuessTooBig(uint64 q, uint64 valHi, uint32 valLo, uint32 divHi, uint32 divLo);
2792 static uint32 AddDivisor(uint32* left, int32 leftLength,
const uint32* right, int32 rightLength);
2793 static uint32 SubtractDivisor(uint32* left,
int leftLength,
const uint32* right,
int rightLength, uint64 q);
2796 static bool GcdLehmerIteration(uint64& x, uint64& y, uint32& a, uint32& b, uint32& c, uint32& d, int32& iteration);
2797 static int32 GcdGuessLehmer(
const FBigInteger& lhs,
const FBigInteger& rhs, uint32& a, uint32& b, uint32& c, uint32& d);
2798 static void GcdLehmerCore(
FBigInteger& lhs,
FBigInteger& rhs, uint32& a, uint32& b, uint32& c, uint32& d, int32 iteration);
2800 void DecrementCore();
2801 void IncrementCore();
2803 void SetSignInCore(int32 value);
2805 uint32 GetBitsOrZero(int32 index)
const;
2806 void EnsureLength(int32 length);
2809 static const int32 bitsPerUnit = 32;
2813#if DBN_INLINE_ENABLED
2814#include "BigInteger.inl"
Definition: BigInteger.h:50
void SetValueIn(const TArray< uint8 > &magnitude, bool isNegative)
bool CanFitIntoInt() const
FBigInteger Pow(float exponent) const
uint32 DivRem(const uint32 divisor, FBigInteger "ient) const
void GetBaseTwoComponents(uint32 &mantissa, int32 &exponent) const
void SetValueIn(double value)
void AddIn(const FBigInteger &rhs)
void ToggleBitIn(int32 bitIndex)
void SetValueIn(int32 value)
int32 CompareTo(uint64 rhs) const
void OrIn(const FBigInteger &rhs)
void SubtractIn(const FBigInteger &rhs)
void ShiftRightIn(int32 shift)
uint32 FloorLog10() const
void SetValueIn(int64 value)
uint64 DivRem(const uint64 divisor, FBigInteger "ient) const
float LogX(float base) const
void AndIn(const FBigInteger &rhs)
bool CanFitIntoUInt64() const
int32 CompareTo(int64 rhs) const
void ShiftLeftIn(int32 shift)
void SetValueIn(const TArray< uint32 > &value)
int32 CompareMagnitudeTo(const FBigInteger &rhs) const
void SetValueIn(const TArray< uint32 > &magnitude, bool isNegative)
void SetWordIn(int32 index, uint32 word)
int32 CompareTo(uint32 rhs) const
void SetValueIn(uint32 value)
void ClearBitIn(int32 bitIndex)
void XorIn(const FBigInteger &rhs)
void SetBitIn(int32 bitIndex)
FString ToHexString() const
void SetValueIn(const TArray< uint8 > &value)
void SetValueIn(uint64 value)
static FBigInteger Gcd(const FBigInteger &lhs, const FBigInteger &rhs)
bool CanFitIntoInt64() const
FBigInteger Multiply(const FBigInteger &rhs) const
int32 CompareTo(const FBigInteger &rhs) const
double LogX(double base) const
static const FBigInteger Zero
Definition: BigInteger.h:179
int32 CompareTo(int32 rhs) const
static const FBigInteger One
Definition: BigInteger.h:185
FBigInteger Pow(int32 exponent) const
int32 GetSignedBitLength() const
FBigInteger DivRemIn(const FBigInteger &divisor)
void GetBaseTwoComponents(uint64 &mantissa, int32 &exponent) const
static const FBigInteger MinusOne
Definition: BigInteger.h:191
void SetValueIn(float value)