Skip to content

Implements signed and unsigned integers consisting of four constituent parts such as a synthesized 128-bit integer or similar

License

Notifications You must be signed in to change notification settings

ckormanyos/long_long_long

Repository files navigation

long_long_long

Build Status Boost Software License 1.0

This is a legacy project that preserves an old work. New designs should use ckormanyos/wide-integer or boost::multiprecision or similar.

ckormanyos/long_long_long implements signed and unsigned integers consisting of four constituent parts such as a synthesized drop-in replacement for uint128_t or similar.

Use the C++ templates unsigned_long_long_long and signed_long_long_long to create unsigned or signed long long long integers (i.e., like uint128_t). See the detailed example below.

The unsigned_long_long_long and signed_long_long_long template classes are located in namespace math::lll.

#include <math/long_long_long/long_long_long.h>

#include <iostream>

auto main() -> int
{
  using uint128_t = math::lll::unsigned_long_long_long<std::uint32_t>;

  uint128_t p3 { uint128_t { 3 } };

  p3 *= p3;
  p3 *= p3;
  p3 *= p3;
  p3 *= p3;
  p3 *= p3;
  p3 *= p3;

  // 3^64
  const uint128_t
    ctrl
    {
        uint128_t { UINT64_C(1853020188851841) }
      * uint128_t { UINT64_C(1853020188851841) }
    };

  // 3433683820292512484657849089281
  std::cout << "p3: " << p3 << std::endl;

  return (p3 == ctrl) ? 0 : -1;
}

About

Implements signed and unsigned integers consisting of four constituent parts such as a synthesized 128-bit integer or similar

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages