Module safe_math

Module safe_math 

Source
Expand description

Safe Math

This module contains basic functions to perform arithmetic operations on numerical types of the alloy crate and preventing them from overflowing. Should an operation cause an overflow a result containing TradeSimulationError will be returned. Functions for the types I256, U256, U512 are available.

Functions§

_construc_result_i256
_construc_result_u256
_construc_result_u512
div_mod_u256
div_mod_u512
safe_add_i256
safe_add_u256
safe_add_u512
safe_div_i256
safe_div_u256
safe_div_u512
safe_mul_i256
safe_mul_u256
safe_mul_u512
safe_sub_i256
safe_sub_u256
safe_sub_u512
sqrt_u256
Integer square root for U256, returning U256
sqrt_u512
Computes the integer square root of a U512 value using Newton’s method.