unshETH - Dependencies
Math-II.sol
Note
Split reference
This reference file was too long so it is split into multiple chunks. This is chunk number II.
This is a solidity smart contract file that contains several mathematical functions. These functions include square root calculation, logarithm base 2, base 10 and base 256 calculations. The logarithm functions support rounding up or down. All of these functions are defined as internal and pure, which means they only operate on the input arguments and do not modify or rely on any state of the contract.
sqrt
sqrt(uint256 a, Rounding rounding)
This function calculates the square root of a given number. It also supports rounding the result up or down based on the rounding argument.
Parameters
- a uint256: The input number to calculate the square root of.
- rounding Rounding: The rounding direction, either up or down.
Return Values
- uint256: The square root of the input number.
log2
log2(uint256 value, Rounding rounding)
This function calculates the logarithm base 2 of a given number. It also supports rounding the result up or down based on the rounding argument.
Parameters
- value uint256: The input number to calculate the logarithm of.
- rounding Rounding: The rounding direction, either up or down.
Return Values
- uint256: The logarithm base 2 of the input number.
log10
log10(uint256 value, Rounding rounding)
This function calculates the logarithm base 10 of a given number. It also supports rounding the result up or down based on the rounding argument.
Parameters
- value uint256: The input number to calculate the logarithm of.
- rounding Rounding: The rounding direction, either up or down.
Return Values
- uint256: The logarithm base 10 of the input number.
log256
log256(uint256 value, Rounding rounding)
This function calculates the logarithm base 256 of a given number. It also supports rounding the result up or down based on the rounding argument.
Parameters
- value uint256: The input number to calculate the logarithm of.
- rounding Rounding: The rounding direction, either up or down.
Return Values
- uint256: The logarithm base 256 of the input number.