Multiplication result is negative zero

can someone tell me why the output of the code mentioned below is negative zero?

a * b = -0

here 'a' is of type long, b is an object of the decimal class ..... and if a = -28 and b = 0, then the output is -0

+3
source share
2 answers

From Python decimaldocs:

Signed zeros can calculations that are not valid. They keep a sign that would lead if the calculation were performed with greater accuracy. Since their value is zero, both positive and negative zeros are considered equal and their sign is informative.

+7
source

Source: https://habr.com/ru/post/1795002/


All Articles