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
From Python decimaldocs:
decimal
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.
It explains everything:
http://effbot.org/pyfaq/why-are-floating-point-calculations-so-inaccurate.htm
- , , .
Source: https://habr.com/ru/post/1795002/More articles:Description (and many attributes) for User Control does not display information - designКак я могу сигнализировать спящий поток в Java? - javaShould I use (non-blocking) NIO for UDP? - javaConvert Upper Triangular Matrix MATLAB - matlabJava nio udp broadcast - javaSave form data in browser backward or forward - javascriptКак скопировать все элементы по диагонали ниже диагонали в Matlab? - matlabFlask deployment on cherokee and uwsgi - pythonHow to use a partial layout with a collection? Rails - collectionsGet index of objects in java list - javaAll Articles