Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

ops

Mathematical Operations

Core arithmetic and mathematical functions for fixed-point numbers.

Basic Arithmetic

  • add, sub, mul, div - Basic operations
  • neg, abs, rem - Sign and remainder

Rounding

  • floor - Round down (toward negative infinity)
  • ceil - Round up (toward positive infinity)
  • round - Round to nearest (half up)

Power & Exponential

  • exp - Natural exponential (e^x)
  • exp2 - Binary exponential (2^x)
  • exp2_int - Fast 2^x for integer exponents
  • pow - General power function (x^y)
  • sqrt - Square root
  • cbrt - Cube root

Logarithms

  • ln - Natural logarithm
  • log2 - Base-2 logarithm
  • log10 - Base-10 logarithm

Comparison

  • eq, ne - Equality
  • lt, le, gt, ge - Ordering

Fully qualified path: cairo_fp::f128::math::ops

Free functions

absReturns the absolute value of a fixed-point number….
addAdds two fixed-point numbers.
ceilRounds up to the nearest integer (toward positive infinity)….
divDivides two fixed-point numbers….
eqChecks equality of two fixed-point numbers.
expCalculates the natural exponential: e^x…
exp2Calculates the binary exponential: 2^x Supports both positive and negative exponents….
exp2_intFast 2^x for integer exponents. Uses a lookup table for O(1) computation….
floorRounds down to the nearest integer (toward negative infinity)….
ge
gt
le
lnCalculates the natural logarithm: ln(x)…
log2Calculates the base-2 logarithm: log₂(x)…
log10Calculates the base-10 logarithm: log₁₀(x)…
lt
mulMultiplies two fixed-point numbers.
mul_64
ne
neg
powCalculates x^y (power function). Automatically uses a faster algorithm for integer exponents….
pow_int
rem
roundRounds to the nearest integer (half up)….
sqrtCalculates the square root….
cbrtCalculates the cube root. Preserves sign: cbrt(-8) = -2 Useful for 3-asset AMM pool calculations (geometric mean of 3 values)….
sub
_split_unsigned

Structs

f64

Impls