This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: round() combined with product outputs ugly result
Type: Stage: resolved
Components: Versions: Python 3.6
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ronaldoussoren, ursus, xtreak
Priority: normal Keywords:

Created on 2018-08-08 12:26 by ursus, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg323276 - (view) Author: Sandu (ursus) Date: 2018-08-08 12:26
`from scipy import stats`

`a = stats.norm.cdf(2.1882658846227234)`

`round(a,4)` gives:

`round(a,4)*100` one would expect to output 98.57.
It returns:

For comparison, if I multiply with 10 or 1000 the output is as expected.
msg323277 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2018-08-08 13:13
This is expected behaviour, the FAQ entry on floating point gives a good explanation about what's going on here:
Date User Action Args
2022-04-11 14:59:04adminsetgithub: 78539
2018-08-08 14:16:10steven.dapranosetstatus: open -> closed
resolution: not a bug
stage: resolved
2018-08-08 13:13:15ronaldoussorensetnosy: + ronaldoussoren
messages: + msg323277
2018-08-08 12:42:27xtreaksetnosy: + xtreak
2018-08-08 12:26:39ursuscreate