xieite::big_int {}

Defined in header <xieite/math/big_int.hpp>

A class for storing and operating on very large integers.


Definition

template<std::unsigned_integral UInt = std::uint64_t>
struct big_int {
	using type = UInt;

	explicit(false) constexpr big_int(std::integral auto = 0) noexcept;

	template<typename OtherUInt>
	explicit constexpr big_int(const xieite::big_int<OtherUInt>&) noexcept;

	template<std::ranges::input_range Range>
	requires(std::same_as<UInt, std::ranges::range_value_t<Range>>)
	explicit constexpr big_int(Range&&, bool = false) noexcept;

	explicit constexpr big_int(std::string_view, xieite::ssize_t = 10, xieite::number_str_config = {}) noexcept;

	template<std::integral Int>
	explicit constexpr operator Int() const noexcept;

	explicit(false) constexpr operator bool() const noexcept;

	friend constexpr std::strong_ordering operator<=>(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr std::strong_ordering operator<=>(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	friend constexpr bool operator==(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr bool operator==(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt> operator+() const noexcept;

	friend constexpr xieite::big_int<UInt> operator+(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator+(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator+=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator+=(std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator++() noexcept;

	constexpr xieite::big_int<UInt>& operator++(int) noexcept;

	constexpr xieite::big_int<UInt> operator-() const noexcept;

	friend constexpr xieite::big_int<UInt> operator-(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator-(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator-=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator-=(std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator--() noexcept;

	constexpr xieite::big_int<UInt>& operator--(int) noexcept;

	friend constexpr xieite::big_int<UInt> operator*(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator*(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator*=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator*=(std::integral auto) noexcept;

	friend constexpr xieite::big_int<UInt> operator/(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator/(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator/=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator/=(std::integral auto) noexcept;

	friend constexpr xieite::big_int<UInt> operator%(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator%(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator%=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator%=(std::integral auto) noexcept;

	constexpr xieite::big_int<UInt> operator~() const noexcept;

	friend constexpr xieite::big_int<UInt> operator&(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator&(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator&=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator&=(std::integral auto) noexcept;

	friend constexpr xieite::big_int<UInt> operator|(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator|(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator|=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator|=(std::integral auto) noexcept;

	friend constexpr xieite::big_int<UInt> operator^(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator^(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator^=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator^=(std::integral auto) noexcept;

	friend constexpr xieite::big_int<UInt> operator<<(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator<<(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator<<=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator<<=(std::integral auto) noexcept;

	friend constexpr xieite::big_int<UInt> operator>>(const xieite::big_int<UInt>&, const xieite::big_int<UInt>&) noexcept;

	friend constexpr xieite::big_int<UInt> operator>>(const xieite::big_int<UInt>&, std::integral auto) noexcept;

	constexpr xieite::big_int<UInt>& operator>>=(const xieite::big_int<UInt>&) noexcept;

	constexpr xieite::big_int<UInt>& operator>>=(std::integral auto) noexcept;

	constexpr xieite::big_int<UInt> abs() const noexcept;

	constexpr xieite::big_int<UInt> pow(xieite::big_int<UInt>) const noexcept;

	template<std::integral Int>
	constexpr xieite::big_int<UInt> pow(std::integral auto) const noexcept;

	constexpr xieite::big_int<UInt> root(const xieite::big_int<UInt>&) const noexcept;

	constexpr xieite::big_int<UInt> root(std::integral auto) const noexcept;

	constexpr xieite::big_int<UInt> log(const xieite::big_int<UInt>&) const noexcept;

	constexpr xieite::big_int<UInt> log(std::integral auto) const noexcept;

	constexpr xieite::big_int<UInt> str(xieite::ssize_t = 10, xieite::number_str_config = {}) const noexcept;
};


Example

int main() {
	xieite::dump(xieite::big_int(99).pow(99).str());
}
Output:
369729637649726772657187905628805440595668764281741102430259972423552570455277523421410650010128232727940978889548326540119429996769494359451621570193644014418071060667659301384999779999159200499899
[View in Compiler Explorer]