Deveel Math Documentation

May 28, 2026 ยท View on GitHub

Welcome to the Deveel Math documentation. This guide covers arbitrary-precision arithmetic in .NET using the BigDecimal and BigInteger types.

What is Deveel Math?

Deveel Math is a .NET library providing arbitrary-precision decimal and integer arithmetic. It is a port of the Java java.math package from Apache Harmony, adapted for the .NET ecosystem.

TypeDescription
BigDecimalArbitrary-precision decimal numbers with configurable precision and rounding
BigIntegerArbitrary-precision integers with arithmetic, bitwise, and primality support

Why Use Deveel Math?

Feature.NET Built-inDeveel Math
BigIntegerSystem.Numerics.BigIntegerDeveel.Math.BigInteger
BigDecimalNot availableDeveel.Math.BigDecimal
Configurable roundingNoYes (MathContext, RoundingMode)
IEEE 754r precision formatsNoYes (Decimal32, Decimal64, Decimal128)
Java-compatible behaviorNoYes
Primality testingNoYes (IsProbablePrime, NextProbablePrime)

Installation

dotnet add package dmath

Quick Start

BigDecimal Example

using Deveel.Math;

var price = BigDecimal.Parse("19.99");
var quantity = new BigDecimal(3);
var taxRate = BigDecimal.Parse("0.0875");

var subtotal = price * quantity;
var tax = (subtotal * taxRate).ScaleTo(2, RoundingMode.HalfUp);
var total = subtotal + tax;

Console.WriteLine($"Total: {total}"); // 65.22

BigInteger Example

using Deveel.Math;

var a = BigInteger.Parse("123456789012345678901234567890");
var b = BigInteger.Parse("987654321098765432109876543210");

Console.WriteLine($"Product: {a * b}");
Console.WriteLine($"GCD: {BigMath.Gcd(a, b)}");

Documentation Pages

PageContent
BigDecimalCreation, parsing, conversion, operators, arithmetic methods, scale & precision, formatting
BigIntegerCreation, parsing, conversion, operators, arithmetic, modular math, bit operations, primality
MathContext & RoundingModePrecision control, all 8 rounding modes, predefined IEEE 754r contexts
Advanced Math OperationsBigMath static class, advanced division, powers, random generation, primality testing
InteroperabilityBigInteger vs System.Numerics, type conversion tables, primitive conversions, parsing deep dive
Performance BenchmarksBenchmark results vs .NET built-in types across .NET 6.0-10.0

Building & Testing

dotnet restore && dotnet build && dotnet test

License

Apache License 2.0