Important decimal point operations
1. sqrt () : — This function calculates the square root of a decimal number.
2. exp () : — This function returns e ^ x (exponent) decimal.
The exponent of decimal number is: 90.01713130052181355011545675 The square root of decimal number is: 2.121320343559642573202533086
3. ln () : — This function is used to calculate the natural logarithm decimal number.
4. log10 () : — This function is used to calculate the log (base 10) decimal.
The natural logarithm of decimal number is: 1.504077396776274073373258352 The log (base 10) of decimal number is: 0.6532125137753436793763169118
5. as_tuple () : — returns a decimal number as a tuple containing 3 arguments, sign (0 for +, 1 for -), digits, and an exponent .
6. fma (a, b) : — this "fma" means merged multiply and add . It calculates (num * a) + b from the numbers in the argument. In this function no rounding (num * a) is performed.
decimal . Decimal (5). Fma (2,3) - & gt; (5 * 2) +3 = 13
The tuple form of decimal number is: DecimalTuple (sign = 1, digits = (4, 5), exponent = -1) The fused multiply and addition of decimal number is: 13 pre>
7. compare () : — This function is used to compare decimal numbers. Returns 1 if the 1st decimal argument is greater than the 2nd, -1 if the 1st decimal argument is less than the 2nd, and 0 if both are equal.
8. compare_total_mag () : — compares the total value of decimal numbers. Returns 1 if the 1st decimal argument is greater than the 2nd (ignoring the sign), -1 if the 1st decimal argument is less than the 2nd (ignoring the sign), and 0 if both are equal (ignoring the sign).
The result of comparison using compare () is: 1 The result of comparison using compare_total_mag () is: -1
9. copy_abs () : — This function prints the absolute value of the decimal argument.
10. copy_negate () : — This function prints the negation of the decimal argument.
11. copy_sign () : — This function prints the first argument, copying the character from the second argument .
The absolute value using copy_abs () is: 9.5600000000000004973799150320701301097869873046875 The negated value using copy_negate () is: 9.5600000000000004973799150320701301097869873046875 The sign effected value601097869873046875 The sign effected value601097869873046875 The sign effected value60: copy_sign () > 12. max () : — this function calculates a maximum of two decimal numbers.
13. min () : — This function calculates the minimum of two decimal numbers.
The minimum of two numbers is: 7.429999999999999715782905696 The maximum of two numbers is: 9.529999999999999360511537816 pre >
This article is courtesy of Mange it Singh . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.
Learning to code is tremendous fun as you can get instant results, no matter how much more you have to learn. In fact, it’s such fun creating games and programs that it feels effortless once you’r...
Computer Age Statistical Inference: Algorithms, Evidence, and Data Science (Institute of Mathematical Statistics Monographs, Series Number 6). The twenty-first century has seen a breathtaking expan...
The field of Artificial Intelligence (AI), which can definitely be considered to be the parent field of deep learning, has a rich history going back to 1950. While we will not cover this history in mu...
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow: Concepts, Tools, and Techniques to Build Intelligent Systems PDF, 2nd Edition. This book assumes you know next to nothing about m...