#bignum #number

nightly ramp

A high-performance multiple-precision arithmetic library

45 releases

Uses old Rust 2015

0.7.0 Apr 23, 2022
0.6.0 Jun 2, 2021
0.5.9 Aug 14, 2020
0.5.8 Jul 19, 2020
0.1.6 Jun 24, 2015

#434 in Math

Download history 112/week @ 2023-11-03 99/week @ 2023-11-10 164/week @ 2023-11-17 162/week @ 2023-11-24 193/week @ 2023-12-01 138/week @ 2023-12-08 164/week @ 2023-12-15 183/week @ 2023-12-22 97/week @ 2023-12-29 98/week @ 2024-01-05 117/week @ 2024-01-12 167/week @ 2024-01-19 122/week @ 2024-01-26 87/week @ 2024-02-02 160/week @ 2024-02-09 550/week @ 2024-02-16

926 downloads per month
Used in 6 crates




This crate is no longer being maintained.

Fortunately, there's lots of alternatives to ramp. Thanks for the good times :`)

RAMP - Rust Arithmetic in Multiple Precision

Build Status Version Docs

Ramp is a high-performance multiple-precision (aka "BigNum") library for working with numbers bigger than can normally be handled. Usage is very easy, you can almost use them as regular numbers.


extern crate ramp;
use ramp::Int;

// Calculates n!
fn factorial(n: usize) -> Int {
   let mut a = Int::from(1);

   for i in 2..n {
       a *= i;

   return a * n;

As you can see, it is very easy to work with these numbers.

Operator overloads have been provided for by-value, which consumes the operand(s) and by-reference, which does not. The by-value overloads will attempt to re-use the space for the result (this isn't always possible).

Operator overloads have also been provided for i32 and usize, allowing easy (and efficient) operations when you have smaller numbers. The above example actually uses the usize overload, meaning only one Int is ever allocated.

NOTE Due to use of unstable features (notably inline assembly), Ramp can only be compiled with a nightly build of rustc.

Why another library?

The num crate provides some bignum types that can be used, so why use Ramp? Well, Ramp is specifically focussed on multiple-precision arithmetic, while num is a general-purpose numerics library that happens to provide some multiple-precision arithmetic.

You should num if you aren't able to use unstable Rust features or just want a small amount of functionality. Ramp should be used when you need high-performance and extra functionality.

Overall Design

Ramp is split into two main parts: high-level code and low-level code. The high-level code is what you should be using, however the low-level code is where the real work is done.

The low-level routines (in ll) are predominantly unsafe functions that work with raw pointers, and some of the routines are implemented using inline assembly to gain access to processor-specific functionality.


The term "Limb" is used frequently in Ramp. It's a term borrowed from GMP and is a single "digit" for the base that Ramp works in. Since the base is equal to 2^word_size, these are very large "digits", hence the use of the word "Limb" instead.

Future Work

Ramp is currently very rough and incomplete. Broadly, there are three types Ramp aims to provide: integers, rationals, and floats. Integers (Int) are present and mostly complete, Rationals are present and have a basic implementation. Floats are not yet implemented.

In the low-level routines, there are a few operations, notably multiplication and division, that are currently implemented using the simplest working algorithm. While this is sufficient for relatively small numbers, larger numbers should be using better algorithms.


~15K SLoC