Skip to main content

Crate pallas_math

Crate pallas_math 

Source
Expand description

Fixed-precision arithmetic for the parts of the Cardano protocol that need ln, exp, and pow to high precision.

The Praos VRF leader-check formula and the reward / pool-saturation calculations both require deterministic transcendental math; this crate supplies it. Backed by dashu for the underlying big-integer representation.

§Usage

use pallas_math::math::{FixedDecimal, FixedPrecision};

let x = FixedDecimal::from_str("2", 34)?;   // 2.0 with 34 fractional digits
let y = x.ln();                             // ≈ 0.6931471805599453…
println!("ln(2) ≈ {y}");

§Overview

§Usage as part of pallas

pallas-math is not currently re-exported from the umbrella pallas crate; depend on it directly.

Modules§

math
Public surface: the math::FixedDecimal type, the math::FixedPrecision trait, and the shared constants.
math_dashu
dashu-backed implementation of math::FixedPrecision.