Precision Without Limits
BigFloat revolutionizes numerical computing by providing arbitrary-precision arithmetic with sophisticated guard bit mechanisms and advanced rounding algorithms.
Scale-Based Architecture
Unlike traditional IEEE floating-point exponents, BigFloat uses a scale-based approach measuring the radix point from the least significant digit, providing more intuitive precision control.
Guard Bit Technology
32 hidden guard bits maintain accuracy during sequential operations, preventing cumulative rounding errors that plague traditional floating-point arithmetic.
Mathematical Constants
Access pre-computed mathematical constants like π, e, and others with precision up to 1 million decimal digits, perfect for scientific and research applications.
Advanced Features
Built for demanding computational scenarios where precision is paramount.
Flexible Precision
Mantissa size up to 2 billion bits allows for unprecedented precision in numerical calculations, limited only by available memory.
Two's Complement
Uses two's complement representation for efficient arithmetic operations, leveraging the underlying BigInteger implementation.
Smart Rounding
Advanced rounding algorithms that check the most significant removed bit and apply appropriate rounding to maintain precision across operations.
Modern C# Integration
Built for C# 11/.NET 7+ with full operator overloading, implicit conversions, and seamless integration with existing .NET applications.
Comprehensive Math Library
Extended mathematical functions including logarithms, square roots, exponentials, and trigonometric operations with high precision.
Performance Optimized
Optimized for performance with caching mechanisms, efficient bit operations, and minimal memory allocation during calculations.
Architecture Deep Dive
Understanding the innovative design that makes BigFloat uniquely powerful.
Mantissa (DataBits)
Scale
Size (Cached)
32 Guard Bits
Scale vs. Exponent
Unlike IEEE floating-point's left-measured exponent, BigFloat's scale measures the radix point from the right (least significant digit), providing more intuitive control over decimal placement and precision.
Guard Bit Mechanism
The 32 hidden guard bits act as a precision buffer, maintaining accuracy during sequential operations. They correct cumulative rounding errors that would otherwise degrade precision over multiple calculations.
Precision Notation
BigFloat defaults its output to scientific notation to express precision (e.g., 2.32e10). However, it also supports a unique output and input notation (e.g., "232XXXXXXXX") where imprecise portions are marked with X's, ensuring users understand the reliability of each digit.
Code Examples
Explore BigFloat's capabilities with code examples.
Basic Arithmetic & Operations
// Initialize BigFloat numbers
BigFloat a = new("123456789.012345678901234"); // by String
BigFloat b = new(1234.56789012345678); // by Double
// Basic arithmetic
BigFloat sum = a + b;
BigFloat difference = a - b;
BigFloat product = a * b;
BigFloat quotient = a / b;
// Display results
Console.WriteLine($"Sum: {sum}");
Console.WriteLine($"Difference: {difference}");
Console.WriteLine($"Product: {product}");
Console.WriteLine($"Quotient: {quotient}");
// Comparing Numbers
BigFloat num1 = new("12345.6790");
BigFloat num2 = new("12345.6789");
bool areEqual = num1 == num2;
bool isFirstBigger = num1 > num2;
Console.WriteLine($"Are equal? {areEqual}"); // False
Console.WriteLine($"First bigger? {isFirstBigger}"); // True
Live Output
High-Precision Constants
// Access constants with specified precision
Dictionary<string, BigFloat> bigConstants =
Constants.WithConfig(precisionInBits: 1000).GetAll();
BigFloat pi = bigConstants["Pi"];
BigFloat e = bigConstants["E"];
Console.WriteLine($"e to 1000 binary digits: {e}");
// Use Pi in calculations
BigFloat radius = new("100.0000000000000000");
BigFloat area = pi * radius * radius;
Console.WriteLine($"Circle area: {area}");
Precision Demonstration
Precision Manipulation
// Initialize with high precision
BigFloat preciseNumber = new("123.45678901234567890123");
// Extend precision by adding bits
BigFloat morePrecise = ExtendPrecision(
preciseNumber, bitsToAdd: 50);
Console.WriteLine($"Extended: {morePrecise}");
// Create integer with custom precision
BigFloat customInt = IntWithAccuracy(10, 100);
Console.WriteLine($"Custom int: {customInt}");
// Precision notation examples
Console.WriteLine("232XXXX -> " + BigFloat.Parse("232XXXX"));
Console.WriteLine("232X.X -> " + BigFloat.Parse("232X.X"));
Precision Control Results
Advanced Operations & Large Numbers
// Handling Very Large Numbers
BigFloat largeNumber = new("1234e+7");
Console.WriteLine($"Large: {largeNumber}");
// Alternative notation with masking
Console.WriteLine($"Masked: {BigFloat.ToStringDecimal(largeNumber, digitMaskingForm: true)}");
// Very large exponents
BigFloat veryLarge = new("1234e+300");
Console.WriteLine($"Very large: {veryLarge}");
// Very small numbers
BigFloat smallNumber = new("1e-300");
Console.WriteLine($"Small: {smallNumber}");
// Complex calculations
BigFloat num5 = new("12121212.1212");
BigFloat num6 = new("1234567");
Console.WriteLine($"{num5} * {num6} = {num5 * num6}");
Console.WriteLine($"Precision: {num6.Precision}");
Advanced Results
Performance & Precision
Benchmarks and precision analysis demonstrating BigFloat's capabilities.
Guard Bit Effectiveness
After 2⁴⁰ sequential operations, rounding maintains precision within guard bits.
Precision Scaling
Memory Efficiency
Get Started
Quick installation and integration into your C# projects.
NuGet Package
Install-Package BigFloatLibrary
or via .NET CLI:
dotnet add package BigFloatLibrary
GitHub Source
git clone https://github.com/SunsetQuest/BigFloat.git
Add the source files directly to your project for maximum customization.
Requirements
- C# 11 or later
- .NET 7 or later
- System.Numerics.BigInteger support
Quick Start Example
using BigFloatLibrary;
// Create your first BigFloat
BigFloat number = new("123.456789012345678901234567890");
BigFloat doubled = number * 2;
Console.WriteLine($"Original: {number}");
Console.WriteLine($"Doubled: {doubled}");
Documentation & Resources
Comprehensive guides, API references, and community resources.
API Reference
Complete documentation of all classes, methods, and properties with detailed examples.
View Documentation →Getting Started Guide
Step-by-step tutorials to get you up and running with BigFloat in your projects.
Read Guide →Code Examples
Real-world examples and use cases demonstrating BigFloat's capabilities.
Browse Examples →Release Notes
Version history, changelog, and what's new in the latest releases.
View Releases →Community Support
Get help, report bugs, or contribute to the BigFloat community.
Join Community →Technical Article
In-depth technical analysis and implementation details published on CodeProject.
Read Article →