MeshLib C++ Docs
Loading...
Searching...
No Matches
MRFastInt.h File Reference
#include "MRMeshFwd.h"
#include "MRFastInt128.h"
#include <MRPch/MRBindingMacros.h>
#include <array>
#include <cassert>
#include <compare>
#include <cstdint>
#include <type_traits>

Go to the source code of this file.

Classes

class  MR::FastInt< nBits >
class  MR::Int128Mul256

Namespaces

namespace  MR
 only for bindings generation
namespace  MR::detail

Typedefs

using MR::FastInt256 = FastInt<256>
using MR::FastInt512 = FastInt<512>
using MR::FastInt1024 = FastInt<1024>
using MR::Vector2i128mul = Vector2<Int128Mul256>
 no bindings for the same reason as for Vector3i128fast
using MR::Vector3i128mul = Vector3<Int128Mul256>

Functions

constexpr std::uint64_t MR::detail::addCarry64 (std::uint64_t a, std::uint64_t b, std::uint64_t &carry) noexcept
 returns a + b + carry modulo 2^64, and replaces carry with the carry-out (0 or 1)
constexpr std::uint64_t MR::detail::subBorrow64 (std::uint64_t a, std::uint64_t b, std::uint64_t &borrow) noexcept
 returns a - b - borrow modulo 2^64, and replaces borrow with the borrow-out (0 or 1)
constexpr std::uint64_t MR::detail::signWord (std::uint64_t hi) noexcept
 all ones if the highest bit of the given word is set, and zeros otherwise
template<std::size_t n, std::size_t m>
constexpr std::array< std::uint64_t, n+m > MR::detail::mulWords (const std::array< std::uint64_t, n > &a, const std::array< std::uint64_t, m > &b) noexcept
 std::size_t and not int, to be deducible from std::array
template<typename T>
constexpr auto MR::detail::mulWordsOf (T v) noexcept
 the words of a multiplier of FastInt, sign-extended if it is signed
double MR::detail::doubleFromWords (const std::uint64_t *w, int n) noexcept
MR_BIND_IGNORE double MR::toDouble (FastInt128 v) noexcept
template<int nBits>
MR_BIND_IGNORE double MR::toDouble (const FastInt< nBits > &v) noexcept
 the nearest double to the given value, with the same guarantees as toDouble( FastInt128 ) above
template<int nBits, int mBits>
MR_BIND_IGNORE constexpr FastInt< nBits+mBits > MR::operator* (const FastInt< nBits > &a, const FastInt< mBits > &b) noexcept
template<int nBits, typename T>
requires detail::cFitsFastInt128<T>
MR_BIND_IGNORE constexpr FastInt< nBits+detail::cMulBits< T > > MR::operator* (const FastInt< nBits > &a, T b) noexcept
template<int nBits, typename T>
requires detail::cFitsFastInt128<T>
MR_BIND_IGNORE constexpr FastInt< nBits+detail::cMulBits< T > > MR::operator* (T a, const FastInt< nBits > &b) noexcept

Variables

template<typename T>
constexpr bool MR::detail::cFitsFastInt128 = std::is_integral_v<T> || std::is_same_v<T, FastInt128>
 the integer types that FastInt128 represents exactly, and which the classes below accept
template<typename T>
constexpr int MR::detail::cMulBits = std::is_same_v<T, FastInt128> || ( std::is_unsigned_v<T> && sizeof( T ) >= 8 ) ? 128 : 64