Grint

A library for calculations with numbers of arbitrary lenght

Overview

Grint is a library designed for calculations with numbers of arbitrary length. The name “Grint” is a blend created by combining the words greater and int (integer).

This project was created as an educational project and is one of my first C programming projects, developed in 2023. Its goal was to explore how arbitrary-precision arithmetic works internally and to gain a deeper understanding of low-level number representations and algorithms.

Currently available arithmetic operations include:

  • Comparison (>, <, =)
  • Addition
  • Subtraction
  • Multiplication
  • Division

Implementation Details

Grint is implemented in ANSI C.

Internally, numbers are stored as dynamic arrays of integers, where each bit of the stored integers is used to represent the number. This allows the library to represent integers with arbitrary bit length, limited only by available memory.

The multiplication algorithm currently implemented is the schoolbook multiplication method, which mirrors the traditional manual multiplication technique. While not the fastest algorithm for extremely large numbers, it is straightforward to implement and ideal for educational purposes.

Key technical aspects:

  • Language: ANSI C

  • Internal representation: dynamic array of integers storing arbitrary-length bit sequences

  • Precision: arbitrary-bit integers (limited only by memory)

  • Multiplication algorithm: schoolbook multiplication

Motivation

Before starting this project, I wrote a program to calculate the square root of a number using the “shifting nth root” algorithm. This algorithm allows the calculation of square roots to a massive number of decimal places.

However, during runtime certain parameters within the algorithm continuously grow larger. Because of this, standard data types quickly overflow. I therefore needed a custom solution capable of handling extremely large numbers, which ultimately led to the creation of Grint.

Used Environment

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

View this project on GitHub

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.