Coder Social home page Coder Social logo

tringi / doubleinteger Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 1.0 18 KB

C++ large integer template, which doubles the width of little-endian integers and can be nested

C++ 100.00%
128-bit cpp integer 256-bit 512-bit header-only large-integer large-integers

doubleinteger's Introduction

template double_integer <LO, HI>

Formerly simple int128 class for a bytecode interpreter project long forgotten. Rewritten several times, now supporting much more that originally envisioned, most importantly being usable transparently as if intrinsic integer type.

Usage

#include <double_integer.hpp>

typedef double_integer <unsigned long long,   signed long long>  int128_t;
typedef double_integer <unsigned long long, unsigned long long> uint128_t;

typedef double_integer <uint128_t,  int128_t>  int256_t;
typedef double_integer <uint128_t, uint128_t> uint256_t;

// ...

Key features

  • Binary layout of objects is the same as the data type they simulate for little-endian platform, P.O.D. aka “standard layout type”.
    • copy in/out using std::memcpy
  • The std::numeric_limits is correctly overloaded for every instantiated double_integer.
  • Nesting instantiations is valid way to create 256-bit integers, 512-bit integers and even arbitrarily larger ones.

Notes

  • Review needed for constexpr correctness and for possible simplifications with latest C++.
  • Features that I don't use in my projects may not be as thoroughly tested as the rest of the code.

License

This project is a free software available under the zlib license.

doubleinteger's People

Contributors

tringi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

yyinhai

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.