Message367737
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. |
|
Date |
User |
Action |
Args |
2020-04-30 05:34:53 | steven.daprano | set | recipients:
+ steven.daprano, b_ICT |
2020-04-30 05:34:53 | steven.daprano | link | issue40446 messages |
2020-04-30 05:34:52 | steven.daprano | create | |
|