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.

Author steven.daprano
Recipients b_ICT, steven.daprano
Date 2020-04-30.05:34:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20200430053041.GA26597@ando.pearwood.info>
In-reply-to <1588223600.07.0.719223766764.issue40446@roundup.psfhosted.org>
Content
Hi,

The behaviour you are calling "gibbrish" is correct, as the expression 
`(p-1)/2` calculates a 64-bit floating point number, which may lose 
precision even for small values of p, but will definitely lose precision 
for large p.

Calling `int()` on that float will not recover the lost precision.

So there is no bug here, this is expected behaviour with floats. Please 
remember that floats are not mathematically exact Real numbers like we 
learn about in school, they have limited precision.

To avoid the float conversion, use the floor-division operator 
`(p-1)//2` as you mention. If `p` is an int, the result will be exact.
History
Date User Action Args
2020-04-30 05:34:53steven.dapranosetrecipients: + steven.daprano, b_ICT
2020-04-30 05:34:53steven.dapranolinkissue40446 messages
2020-04-30 05:34:52steven.dapranocreate