Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

u256_mul_div

Returns the quotient of x * y / denominator and rounds up or down depending on rounding. Uses wide_mul and u512_safe_div_rem_by_u256 for precision.

Requirements:

  • denominator must not be zero.
  • The quotient must not overflow u256.

Fully qualified path: openzeppelin_utils::math::u256_mul_div

pub fn u256_mul_div(x: u256, y: u256, denominator: u256, rounding: Rounding) -> u256