Projects

Grint

C / Arbitrary-Precision Arithmetic

An educational ANSI C library for arithmetic with arbitrary-bit integers.

Overview

Grint is a library designed for calculations with numbers of arbitrary length. Its name combines the words greater and int.

I created it in 2023 as one of my first C programming projects to explore arbitrary-precision arithmetic, low-level number representations, and the algorithms behind them.

Operations

Comparison, addition, subtraction, multiplication, and division.

Precision

Arbitrary-bit integers limited only by available memory.

Language

Implemented in ANSI C as an educational library.

Implementation Details

Internally, Grint stores numbers as dynamic arrays of integers. Each bit of those stored integers contributes to the represented number, allowing values to grow beyond standard fixed-size data types.

Multiplication currently uses the schoolbook method. It mirrors the traditional manual multiplication technique, which makes it straightforward to implement and useful for learning even though faster algorithms exist for extremely large numbers.

Key Technical Aspects

  • Language: ANSI C
  • Representation: dynamic integer arrays for bit sequences
  • Precision: arbitrary-bit integers
  • Multiplication: schoolbook multiplication

Used Environment

  • Windows 11
  • Visual Studio 2022 (17.8.6)
  • Atlassian Sourcetree (optional)

Motivation

Before Grint, I wrote a program that calculated square roots with the shifting nth root algorithm. Some runtime parameters grew too large for standard data types, so I needed a custom number representation that could handle very large values.

Comments

0

Loading comments...