How can we control the rounding of our equation?

    0.20
  + 0.69
  -------
    0.89
    0.53
  x 0.65
  ------
     265
    3180
  ------
  0.3445

The number of decimal places is derived from the arithmetic.

Hi mtf. Thanks for your response. What happens if, say, I want the first equation to print(one_decimal_point) instead of two? …

two_decimal_points = Decimal(β€˜0.2’) + Decimal(β€˜0.69’)
… somehow get to an output of …
β†’ only 0.9 …?

I see your example and it makes sense … but if what you say is true, then why in the lesson for this concept does the example produce a long string of numbers instead of just two decimals like what I wrote in green?

Is it that by adding (in front of the number) the word Decimal, we’re telling the computer to β€œHey, this number has two decimals so stick with a two decimal result?” Also, the lesson says that Decimal is a data type … which came from inside the decimal library/module right? Data type. Exactly like how strings and boolean are data types too right? So Decimal is NOT a function?

It will be helpful to have the documentation on hand when working with this module, at least until it is committed to memory.

1 Like

Thank you for this reference. I will study it!

1 Like