Decimal Functions in Python- Set 1:

Operations on decimals in Python for Data Science:

  1. sqrt(): It is a function that computes the square root of a decimal number.
  2. exp(): It is a function that returns the e^x exponent of a decimal number.Decimal Functions in Python for Data Science - Set 1 - PST Analytics
  3. ln(): It is a function for computation of natural log of a decimal number.
  4. log10(): It is a function that is there for computation of log (base 10) of a decimal number.
  5. as_tuple(): It returns the decimal number as a tuple consisting of three arguments, sign (0 for + and 1for-), digits and exponent value.
  6. fma(a,b): fma stands for fused multiply and add. It is there for computation of (num*a) + b from the numbers provided in the argument. There is no rounding of (num*a) in this function.Decimal Functions in Python for Data Science - Set 1 - PST Analytics
  7. compare():

    It is a function for the comparison of decimal numbers. It will return 1 if the first decimal argument is greater than the second one, -1 if the decimal argument is smaller than the second and 0 if both of them are equal. The signs of the arguments are neglected.

  8. compare_total_mag(): It compares the total magnitude of decimal numbers. It will return 1 if the first decimal argument is greater than the second one, -1 if the decimal argument is smaller than the second and 0 if both of them are equal. So, the signs of the arguments are neglected.
  9. copy_abs(): It is a function that prints the absolute value of a decimal number provided as argument.
  10. copy_negate(): It is a function that prints the negation of a decimal number provided as argument.
  11. copy_sign(): It is a function that will print the first argument provided, but it will take the sign from the second argument.
  12. max(): It is a function for computing the maximum of two decimal numbers.
  13. min(): It is a function for computing the minimum of two decimal numbers.

So, to learn more about operations in python for data science, you can check this and this as well.

Leave a Reply

Your email address will not be published. Required fields are marked *