Giter VIP home page Giter VIP logo

aarith's Introduction

Linux CI Documentation Status

Aarith: An Arbitrary Precision Number Library

Aarith is a header-only, arbitrary precision number library for C++. It is intended to be used as a drop-in replacement of the native data types.

Aarith currently supports

  • IEEE 754 like floating-point numbers of arbitrary bit-width for both, the exponent and the mantissa
  • Two's complement integers of arbitrary bit-width (signed and unsigned)

Read the full documentation

Installation

Copy the contents of this repository into a <destination> folder and include Aarith in your CMake build using:

add_subdirectory(<destination>)

You can then link your target <targetname> against Aarith with:

target_link_libraries(<targetname> PUBLIC aarith::Library)

Usage Example

Aarith is intended to be used as a drop-in replacement for the native data types. You only need to include the headers and can start using Aarith immediately:

#include <aarith/float.hpp>
#include <aarith/integer.hpp>

int main()
{
    using namespace aarith;
    uint64_t a = 10, b = 20;
    uinteger<64> a_ = 10, b_ = 20;
    std::cout << "a + b = " << (a + b) << "\n";
    std::cout << "a_+ b_ = " << (a_ + b_) << "\n";

    float x=3.0F, y=2.5F;
    floating_point<8,23> x_{3.0F}, y_{2.5F};
    std::cout << "x + y = " << (x * y) << "\n";
    std::cout << "x_+ y_ = " << (x_ * y_) << "\n";
}

This gives the expected output of

$ ./arithmetic_example
a + b = 30
a_+ b_ = 30
x * y = 7.5
x_* y_ = 7.5

To make usage of Aarith more convenient, the following type aliases are shipped with Aarith:

using half_precision = floating_point<5, 10, uint64_t>;
using single_precision = floating_point<8, 23, uint64_t>;
using double_precision = floating_point<11, 52, uint64_t>;
using quadruple_precision = floating_point<15, 112, uint64_t>;
using bfloat16 = floating_point<8, 7, uint64_t>;
using tensorfloat32 = floating_point<8, 10, uint64_t>;

Further examples for how to use aarith can be found in the examples and experiments folders (the tests can also give a good idea of how to use aarith).

We also refer the interested user to the publication listed below.

License

Aarith comes under the Apache 2 licence (for detais, see the license file).

Publication

If you use Aarith (e.g., in your publication), please cite

Oliver Keszocze, Marcel Brand, Christian Heidorn, und Jürgen Teich. „Aarith: An Arbitrary Precision Number Library“, In: ACM/SIGAPP Symposium On Applied Computing (SAC'21). March 2021.

Bibtex:

@inproceedings{Keszocze2021,
  title = {Aarith: {{An Arbitrary Precision Number Library}}},
  booktitle = {ACM/SIGAPP Symposium On Applied Computing},
  author = {Keszocze, Oliver and Brand, Marcel and Heidorn, Christian and Teich, Jürgen},
  date = {2021-03},
  location = {{Virtual Event, South Korea}},
  series = {{{SAC}}'21}
}

aarith's People

Contributors

faubrand avatar keszocze avatar kissen avatar loeschmaximilian avatar schustan avatar witterauf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

aarith's Issues

`std::uniform_int_distribution<>` is not defined for `unsigned char`

Several unit tests make use of std::uniform_int_distribution<>, which has the following requirement for its type parameter:

IntType – The result type generated by the generator. The effect is undefined if this is not one of short, int, long, long long, unsigned short, unsigned int, unsigned long, or unsigned long long.

In aarith's test suite there are several instances where std::uniform_int_distribution<> is indirectly instantiated with std::uint8_t, which is unsigned char on most platforms, and hence not supported as a parameter type for std::uniform_int_distribution<>:

  • /tests/core/word_array-generation-test.cpp
  • /tests/integer/uint-random-generation-test.cpp
  • tests/test-signature-ranges.hpp (AARITH_INT_TEST_TEMPLATE_PARAM_RANGE and AARITH_WORD_ARRAY_TEST_TEMPLATE_PARAM_RANGE)
  • ...

Although uint16_t, uint32_t, uint64_t are usually identified with one of unsigned short, unsigned int, unsigned long, or unsigned long long, this is not guaranteed by the standard. It would probably be better not to use sized integer types for std::uniform_int_distribution<> and to stick with the explicitly supported types instead.

Repro: try to build aarith on Windows with MSVC or Clang. Microsoft's STL has a static_assert() enforcing above requirement.

Use CI to test build

We want automatic builds and tests for

  • g++/clang/MSVC
  • Linux / Windows

We did have something up and running for this but it seems to be broken.

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.