Cookbook may introduce a token in the future. Share and contribute to be eligible for future airdrops.

HQ20 Decimal Math

HQ20

• version 1.0.0Utility

Math

1.0.0

HQ20

🍞 0x77eA downloaded

10/17/2022

Any contract you deploy is yours.

Fully owned and controlled by your wallet.

Fully owned and controlled by your wallet.

Documentation

Source Code

unit(uint8) :

This function is used to convert a number with a given number of decimals into its equivalent in base 10. It takes in a uint8 (unsigned 8-bit integer) as an argument, which represents the number of decimals. It then uses the built-in uint256 type to calculate 10 to the power of the number of decimals, and returns the result. The function also includes a require statement to ensure that the number of decimals is not greater than 77. (autogenerated documentation)

addd(uint256,uint256) :

This function adds two uint256 values together and returns the result. It works by taking two uint256 values as parameters, adding them together, and then returning the result. (autogenerated documentation)

addd(int256,int256) :

This function adds two integers together and returns the result. It works by taking two int256 parameters, x and y, and using the add() function to add them together and return the result. (autogenerated documentation)

subd(uint256,uint256) :

This function is an internal pure function that subtracts two unsigned integers (uint256) and returns the result. It works by taking two uint256 parameters, x and y, and subtracting y from x. The result is then returned. (autogenerated documentation)

subd(int256,int256) :

This function is an internal pure function that subtracts two integers and returns the result. It takes two integers (x and y) as parameters and returns the result of subtracting y from x. The function uses the .sub() method to perform the subtraction. (autogenerated documentation)

muld(uint256,uint256) :

This function is an internal pure function that performs a multiplication of two uint256 numbers, x and y. It uses a recursive algorithm to calculate the result, with the maximum number of decimal places set to 18. The function works by breaking down the two numbers into smaller parts and then multiplying them together. The result is then returned as a uint256 number. (autogenerated documentation)

muld(int256,int256) :

This function is an internal pure function that performs a multiplication of two 256-bit integers. It uses a recursive algorithm to break down the multiplication into smaller parts, and then combines the results to get the final product. The function takes two 256-bit integers as parameters and returns the product as a 256-bit integer. (autogenerated documentation)

muld(uint256,uint256,uint8) :

This function is used to perform a multiplication operation on two uint256 values and divide the result by a unit value based on the number of decimals specified. The unit value is calculated by raising 10 to the power of the number of decimals. The result of the multiplication and division is then returned as a uint256 value. (autogenerated documentation)

muld(int256,int256,uint8) :

This function is used to perform a multiplication operation on two 256-bit integers, and then divide the result by a unit of decimals. The unit of decimals is calculated by raising 10 to the power of the decimals argument. The result of the multiplication and division is then returned as a 256-bit integer. (autogenerated documentation)

divd(uint256,uint256) :

This function is an internal pure function that performs a division of two unsigned integers (uint256) and returns the result as an unsigned integer (uint256). It uses a third parameter, 18, to determine the number of decimal places to use in the division. The function works by dividing the two input values and then rounding the result to the specified number of decimal places. (autogenerated documentation)

divd(int256,int256) :

This function is an internal pure function that performs an integer division of two 256-bit integers (x and y). It returns the result of the division as a 256-bit integer. The function works by using a recursive algorithm to divide the two numbers, starting with the most significant bit and working down to the least significant bit. The function also takes an optional third parameter (precision) which specifies the number of decimal places to use in the division. (autogenerated documentation)

divd(uint256,uint256,uint8) :

This function is used to divide two numbers, x and y, and return the result with a specified number of decimal places. It works by first multiplying x by 10^decimals (where decimals is the number of decimal places specified) and then dividing the result by y. The result is then returned as an integer. (autogenerated documentation)

divd(int256,int256,uint8) :

This function is used to divide two integers (x and y) and return the result as an integer with a specified number of decimal places. It works by first multiplying the x value by a unit value (10^decimals) and then dividing it by the y value. The result is then returned as an integer. (autogenerated documentation)

divdr(uint256,uint256) :

This function is an internal pure function that performs a division operation on two unsigned integers (uint256) and returns the result as an unsigned integer (uint256). It uses a recursive approach to divide the two numbers, starting with 18 decimal places of precision and then reducing the precision by one decimal place each time until the result is found. The function works by repeatedly subtracting the divisor (y) from the dividend (x) until the remainder is less than the divisor. The number of times the divisor is subtracted from the dividend is the quotient. (autogenerated documentation)

divdr(int256,int256) :

This function is an internal pure function that performs an integer division with a fixed precision of 18 decimal places. It takes two integers (x and y) as parameters and returns the result of the division as an integer. The function works by first calculating the result of the division as a floating point number, then rounding it to 18 decimal places and finally converting it back to an integer. (autogenerated documentation)

divdr(uint256,uint256,uint8) :

This function is used to divide two numbers and return the result with a specified number of decimal places. It takes three parameters: x, y, and decimals. It first multiplies x by 10^(decimals + 1) and then divides the result by y. It then checks if the last digit of the result is greater than 5, and if so, it adds 1 to the result before returning it. The result is returned with the specified number of decimal places. (autogenerated documentation)

divdr(int256,int256,uint8) :

This function is used to divide two integers and return a result with a specified number of decimal places. It takes three parameters: x, y, and decimals. It first multiplies x by 10^(decimals + 1) and then divides it by y. It then checks the remainder of the division and rounds the result accordingly. If the remainder is greater than 5, the result is rounded up, if the remainder is less than -5, the result is rounded down, and if the remainder is between -5 and 5, the result is rounded to the nearest integer. Finally, the result is divided by 10 and returned. (autogenerated documentation)

divdrup(uint256,uint256) :

This function is an internal function that performs a division operation on two unsigned integers (uint256) and returns the result as an unsigned integer (uint256). It uses a third parameter, 18, to determine the number of decimal places to use in the division. The function works by dividing the two input values and then rounding the result to the specified number of decimal places. (autogenerated documentation)

divdrup(int256,int256) :

This function is an internal pure function that performs an integer division of two 256-bit integers (x and y). It returns the result of the division as a 256-bit integer. The function uses a recursive algorithm to calculate the result, with the third parameter (18) representing the number of decimal places to use in the calculation. (autogenerated documentation)

divdrup(uint256,uint256,uint8) :

This function is used to divide two numbers and return the result with a specified number of decimal places. It works by first multiplying the first number (x) by 10^(decimals + 1) and then dividing it by the second number (y). The result is then rounded up if the last digit is greater than 0. Finally, the result is divided by 10 to get the desired number of decimal places. (autogenerated documentation)

divdrup(int256,int256,uint8) :

This function is used to divide two integers and return the result with a specified number of decimal places. It works by first multiplying the first integer (x) by a unit of 10 to the power of the number of decimal places (decimals + 1). This result is then divided by the second integer (y). Finally, the result is rounded up or down depending on the remainder of the division. (autogenerated documentation)

Share

Download Source

npx cookbookdev i HQ20-Decimal-Math

🍞 0x77eA downloaded

10/17/2022

1.0.0

Cookbook is free.

Any contract you deploy is yours.

Your contract is owned and controlled by you.

Any contract you deploy is yours.

Your contract is owned and controlled by you.