8000 GitHub - sh4ka/big-number: A Rust library to handle big numbers and performing trillions of operations per second
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sh4ka/big-number

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Big Number

A scientific notation number type for idle/incremental games in Rust.

Crates.io Downloads Docs CI

Overview

big_number is a lightweight library that provides a simple implementation of big numbers using scientific notation, specifically designed for incremental/idle games where extremely large numbers are common.

The library represents numbers in the form mantissa * 10^exponent where the mantissa is normalized to be between 1.0 and 10.0 (except for zero).

Installation

Add this to your Cargo.toml:

[dependencies]
big_number = "0.2.0"

Usage

use big_number::BigNumber;

// Create big numbers
let a = BigNumber::new(2.5, 10); // 2.5e10
let b = BigNumber::new(3.0, 5);  // 3.0e5

// Basic operations
let sum = a.add(b);        // Addition
let difference = a.sub(b); // Subtraction
let product = a.mul(b);    // Multiplication
let quotient = a.div(b);   // Division

// Convert to string
println!("a = {}", a.to_string());       // "2.500e10"
println!("a + b = {}", sum.to_string()); // Result of addition

// Helper methods
let zero = BigNumber::zero();
let  class="pl-smi">BigNumber::one();

Features

  • Simple and lightweight implementation
  • Basic arithmetic operations: addition, subtraction, multiplication, division
  • Automatic normalization of scientific notation
  • String representation for display
  • Optimized for performance in idle/incremental game scenarios

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

About

A Rust library to handle big numbers and performing trillions of operations per second

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

0