Skip to content

DreamPast/ulbn

Repository files navigation

ulbn: High-precision Number Library

English 简体中文

Features

  • C89/C++98 compatible (optional C++20 headers available)
  • Minimal hardware assumptions
  • Avoids most UB (Undefined Behavior)
  • Strict boundary checks
  • Custom memory allocator support
  • Most functions are optimized
  • No external dependencies

Dependencies

No external dependencies needed.

ulbn.h/ulbn.c

Minimum C89/C++98, with macros to suggest optimizations for some code.

Hardware Assumptions:

  • Requires CHAR_BIT to be even

ulbn.hpp

Requires the following C++20 features:

  • Concepts and constranints
  • Three-way comparison
  • std::endian
  • std::span
  • std::format (optional)

According to cppreference, the minimum compiler requirements is:

  • GCC 10 (May, 7, 2020)
  • Clang 10 (March, 24, 2020)
  • MSVC 19.26 (May, 19, 2020)

test

Requires the following assumptions for modern platforms:

  • Signed integers are stored in two's complement form
  • float has 23 bits of precision (IEEE754)
  • double has 52 bits of precision (IEEE754)
  • char is 8-bits
  • int64_t exists
  • The platform is little-endian or big-endian
  • <bit>
  • std::format (optional)

Roadmap

  • High-precision integers
    • Arithmetic
      • Faster multiplicatin
        • Karatsuba algorithm (Toom-2)
        • Toom-3 algorithm
        • Toom-4 algorithm
        • FFT
      • Faster base conversion
        • Faster input
        • Faster output
    • Comparison
    • Bitwise Operation
    • Root
    • Number theory functions
      • GCD/LCM
      • Extended GCD
      • Prime number determination
      • Prime number search
      • Factorization
  • High-precision fractions
  • High-precision floating point number
  • High-precision decimal floating point number