Fractional multiplications – unexpected results of positive numbers

Question:

I am getting unexpected results when multiplying 2 fractional numbers.

If i use a calculator (google) to check my sums, i get the correct answer (or the answer i am expecting)

This is an example of the sum i am trying to do
abs(-0.00012437234926353282 * 0.2) (Note: the first number is not always negative, but i want the abs result of the sum).

A calculator gives me this answer: 0.00002487446

But python gives me this 2.4874469852706566e-05

The simple code i am using is this

x = y = round(abs(-0.00012437234926353282 * 0.2), 30)

I am kind of new to Python, please be kind.

I have tried reading up on it, and lots of methods, including floating, rounding and a few more in combinations and different orders, etc (all clearly wrong methods), but all get the "unexpected" results

Asked By: user2125785

||

Answers:

If I am not mistaken, python does give the correct result: 2.4874469852706566e-05 means 2.4874469852706566 * 10**(-5) which is the same as google’s result of 0.00002487446, just rounded to a different decimal place.

Answered By: Nonlinear
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.