Re: [Mingw-w64-public] fix pow() floating point imprecision

2022-06-14 Thread LIU Hao
在 2022-06-14 16:16, g...@m-labs.hk 写道: mingw pow() is the only platform that gives '1e-9 == 10.**-9' is False in Python. It is mentioned here [1]. The issue mentioned that post got an error more than one one you mentioned in this case. I think this problem is more important than the one you m

Re: [Mingw-w64-public] fix pow() floating point imprecision

2022-06-14 Thread gw
On 2022-06-14 15:40, LIU Hao wrote: 在 2022/6/14 10:04, sisyphus 写道: I think the different results can also be expressed as: (1/3) ^ 5 produces 3f70db20a88f4695 1 / (3 ^ 5) produces 3f70db20a88f4696 The latter is a far less error prone approach, and therefore yields the result that should be

Re: [Mingw-w64-public] fix pow() floating point imprecision

2022-06-14 Thread Martin Storsjö
On Tue, 14 Jun 2022, LIU Hao wrote: 在 2022/6/14 10:04, sisyphus 写道: I think the different results can also be expressed as: (1/3) ^ 5 produces 3f70db20a88f4695 1 / (3 ^ 5) produces 3f70db20a88f4696 The latter is a far less error prone approach, and therefore yields the result that should be pr

Re: [Mingw-w64-public] fix pow() floating point imprecision

2022-06-14 Thread LIU Hao
在 2022/6/14 10:04, sisyphus 写道: I think the different results can also be expressed as: (1/3) ^ 5 produces 3f70db20a88f4695 1 / (3 ^ 5) produces 3f70db20a88f4696 The latter is a far less error prone approach, and therefore yields the result that should be provided for (1 / 3) ^ 5. It's not ea

Re: [Mingw-w64-public] fix pow() floating point imprecision

2022-06-13 Thread sisyphus
On Tue, Jun 14, 2022 at 1:57 AM LIU Hao wrote: > ... > I am putting this on hold for a while, until I have some time to look into > it. > > I think the different results can also be expressed as: (1/3) ^ 5 produces 3f70db20a88f4695 1 / (3 ^ 5) produces 3f70db20a88f4696 The latter is a far less e

Re: [Mingw-w64-public] fix pow() floating point imprecision

2022-06-13 Thread LIU Hao
在 2022/6/13 13:06, g...@m-labs.hk 写道: Again, this is correct mathematically. However, the value of (1 / 3) is in fact 0.33... Computer cannot represent the value of '1 / 3' precisely in computer memory under IEEE 754 because of limited size of data type. This function yield a imprecise v

[Mingw-w64-public] fix pow() floating point imprecision

2022-06-12 Thread gw
Dear Sir/Madam, I am writing to inform you the problem of pow() floating point imprecision and am trying to give solution to tackle this problem. As mentioned in here [1], there is a floating point imprecision problem in the pow function. Attached is the patch files to fix this problem and

Re: [Mingw-w64-public] fix pow() floating point imprecision

2022-06-07 Thread LIU Hao
在 2022/6/7 17:11, g...@m-labs.hk 写道: Attached is a patch to fix that. The approach looks credible. However: The proposed solution transforms calculation of `pow(x, y)`, where `y` is negative, into `1 / pow(x, -y)`. This is not strictly equivalent. The maximum value that a `double` may repre

[Mingw-w64-public] fix pow() floating point imprecision

2022-06-07 Thread gw
Dear Sir/Madam, As mentioned in here, there is a floating point imprecision problem in the pow function. Originally, #include #include int main() { union { double d; unsigned long long int i; } cast; cast.d = pow(10., -9); printf("%llx\n", cast.i); return 0; } 3e112e0be826d699 the probl