ABDKMath64x64
The ABDKMath64x64 library provides fixed-point arithmetic operations.
mulu
Calculate x * y
rounding down, where x
is a signed 64.64 fixed-point number, and y
is an unsigned 256-bit integer. Revert on overflow.
Parameters:
x
int128
Signed 64.64 fixed-point number.
y
uint
Unsigned 256-bit integer.
Return Values:
None
uint
Unsigned 256-bit integer.
divu
Calculate x / y
rounding towards zero, where x
and y
are unsigned 256-bit integer numbers. Revert on overflow or when y
is zero.
Parameters:
x
uint
Unsigned 256-bit integer.
y
uint
Unsigned 256-bit integer.
Return Values:
None
int128
Signed 64.64 fixed-point number.
exp_2
The exp_2
function calculates the binary exponent of a given signed 64.64-bit fixed-point number, x
. This function utilizes a series of conditional multiplications based on the bits set in the binary representation of x
. The purpose is to efficiently approximate the value of 2^x
without resorting to iterative calculations, ensuring that the result is a signed 64.64-bit fixed-point number.
Parameters:
x
int128
Signed 64.64 fixed-point number.
Return Values:
None
int128
Signed 64.64 fixed-point number.
divuu
Internal function to calculate x / y rounding towards zero, where x and y are unsigned 256-bit integer numbers. Revert on overflow or when y is zero.
This function is designed to provide a robust and efficient method for dividing two uint256
numbers in a way that accounts for various scenarios, including large numbers and potential overflow issues. The approach combines bit manipulation, conditional statements, and explicit checks to balance performance and accuracy.
Parameters:
x
uint
Unsigned 256-bit integer.
y
uint
Unsigned 256-bit integer.
Return Values:
None
uint128
Unsigned 64.64 fixed-point number.
This library plays a pivotal role in Dyson Finance, notably in the divu
and exp_2
functions, which are extensively employed. These functions are integral to several critical calculations within various contracts:
Last updated