Table of Contents

Numerics & Financial guides

Recipe-style walk-throughs for the Numerics & Financial topic - Bodu.Numerics, the exact-arithmetic value types Fraction<T>, BigDecimal, and Complex<T>, the range type Interval<T> (with its set-algebra family: DiscreteInterval<T>, IntervalPair<T>, and IntervalSet<T>), and the streaming statistics aggregates (RunningStatistics<T>, RunningQuantile<T>, MovingSum<T>, MovingMinMax<T>), and Bodu.Financial, the money, currency, and exchange-rate stack built on top of them.

If you are new to the topic, start with the Numerics & Financial overview for the package boundaries and decision table, and the Numerics & Financial concepts glossary for the shared vocabulary (canonical form, deferred rounding, BigInteger promotion, endpoint inclusivity, minor unit, allocation, provenance).

Bodu.Numerics

Exact rational arithmetic and first-class numeric ranges over the .NET generic-math abstractions.

Overview

The value types, what each is for, and the boundary with Bodu.Financial.

Working with Fraction<T>

Construction, arithmetic, continued fractions, and best rational approximation within a denominator bound.

Working with Interval<T>

Endpoint inclusivity, membership, intersection, union, adjacency, parsing and formatting.

Formatting and parsing Fraction<T>

General, mixed-number, Unicode vulgar-fraction, and percentage specifiers; what the parser accepts; culture and span surfaces.

JSON serialization

Round-tripping Fraction<T> and Interval<T> through System.Text.Json.

Interval algebra

The set-algebra surface of Interval<T> - intersection, union, difference and symmetric difference, unbounded endpoints, the & / | operators, and the N-ary IntervalSet<T>.

Discrete integer intervals

DiscreteInterval<T> - the integer-domain interval with successor-aware emptiness and adjacency, distinct from the continuous Interval<T>.

Generic math constraints

Writing code generic over Fraction<T> and Interval<T> through the .NET INumber<T> / IBinaryInteger<T> abstractions.

Bodu.Numerics API reference

Bodu.Financial

Money with the currency in the type system, the ISO 4217 catalogue, and dated FX with audit-grade provenance.

Overview

What ships in the package and how it pairs with Bodu.Numerics.

Working with Money<TCurrency>

Type-parameter currency, allocation, conversion, exact-arithmetic chains, formatting and parsing, cash rounding.

Monetary precision & unit pricing

Sub-minor-unit prices via explicit-scale Money and unrounded CalculatedMoney, with the scale preserved through arithmetic and every JSON wire shape.

Working with exchange rates

Timeless vs. dated provider contracts, the audit-grade lookup result, the composite fallback stack, and the series / table builders.

Exchange-rate types - a usage-scenario catalogue

Every FX type mapped to the scenario it was defined for, with a "reach for this when…" map and a decision walk-through.

Exchange-rate lookups on a known dataset

One fixed dataset run through every date-resolution policy, tolerance window, and the inverse / identity switches.

Built-in exchange-rate providers

The eleven live-feed packages (BoE, ECB, RBA, Yahoo, OFX, XE, OANDA, Fixer, exchangerate.host, FRED, IMF) - construction, warming, dependency injection, and composing with caching.

Caching and aggregating exchange rates

Read-through caching one provider per cache (CachingRateProvider) and grouping many providers with AggregatingRateProvider - priority fallback, averaging, and per-FX-pair routing.

Testing your own provider

FixedDatedRateProvider as the deterministic test double, and the in-repository contract-test bases the built-in providers pass.

Dependency injection

Register the stack with AddFinancialService(...) - currency lookups, monetary contexts, FX providers, options binding - and the keyed JSON options via AddFinancialJson(...) from the JSON companion.

Bodu.Financial API reference

Suggested reading path

  1. Working with Fraction<T> - the exact-arithmetic foundation everything else leans on.
  2. Working with Interval<T> - ranges as first-class values.
  3. Working with Money<TCurrency> - typed money, allocation, and the ToFraction() bridge back to exact rationals.
  4. Working with exchange rates - the FX provider stack and provenance model.
  5. Dependency injection - let the host compose the stack when you run under Microsoft.Extensions.

See also