Hi Paul,
On Thu, Nov 25, 2021 at 3:24 AM Paul Wise <
[email protected]> wrote:
Giulio Paci wrote:
3) what is the most appropriate solution.
As I understand it, floating point values should not be compared
without some kind of accuracy/precision factor. Zero idea about the
best reference for how to do it correctly, but here is a random one:
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
Thanks for this link.
It is a very great resource and summarizes very well what I already
know about double/float and much more.
Since the test case is dealing with timings, I think the most related
article is [1].
However even after reading that article it seems to me that in this
case it should be reasonable to expect stable behavior of those
operators.
I have uploaded simplified code that showcase the issue and some of
the instabilities [2]. The code seems to behave as if the last value
is different from the other 3, supposed equal values.
I am not even sure what I am seeing in the debugger, since most of the
values are optimized out (and I am not so skilled with debuggers).
[1]
https://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/ [2]
https://pastebin.com/embed_js/T3g560UV
Bests,
Giulio
<div dir="auto"><span style="font-size:12.8px">Hi Paul,</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">On Thu, Nov 25, 2021 at 3:24 AM Paul Wise <</span><a href="mailto:
[email protected]" style="text-
decoration-line:none;color:rgb(66,133,244);font-size:12.8px">
[email protected]</a><span style="font-size:12.8px">> wrote:</span><br style="font-size:12.8px"><span style="font-size:12.8px">> Giulio Paci wrote:</span><br style="font-size:12.8px"><span
style="font-size:12.8px">></span><br style="font-size:12.8px"><span style="font-size:12.8px">> > 3) what is the most appropriate solution.</span><br style="font-size:12.8px"><span style="font-size:12.8px">></span><br style="font-size:12.8px"><
span style="font-size:12.8px">> As I understand it, floating point values should not be compared</span><br style="font-size:12.8px"><span style="font-size:12.8px">> without some kind of accuracy/precision factor. Zero idea about the</span><br style=
"font-size:12.8px"><span style="font-size:12.8px">> best reference for how to do it correctly, but here is a random one:</span><br style="font-size:12.8px"><span style="font-size:12.8px">></span><br style="font-size:12.8px"><span style="font-size:
12.8px">> </span><a href="
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/" style="text-decoration-line:none;color:rgb(66,133,244);font-size:12.8px">
https://randomascii.wordpress.com/2012/02/25/comparing-
floating-point-numbers-2012-edition/</a><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Thanks for this link.</span><br style="font-size:12.8px"><span style="font-size:12.8px">It is a very great resource and
summarizes very well what I already</span><br style="font-size:12.8px"><span style="font-size:12.8px">know about double/float and much more.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Since the test
case is dealing with timings, I think the most related</span><br style="font-size:12.8px"><span style="font-size:12.8px">article is [1].</span><br style="font-size:12.8px"><span style="font-size:12.8px">However even after reading that article it seems to
me that in this</span><br style="font-size:12.8px"><span style="font-size:12.8px">case it should be reasonable to expect stable behavior of those</span><br style="font-size:12.8px"><span style="font-size:12.8px">operators.</span><br style="font-size:12.
8px"><br style="font-size:12.8px"><span style="font-size:12.8px">I have uploaded simplified code that showcase the issue and some of</span><br style="font-size:12.8px"><span style="font-size:12.8px">the instabilities [2]. The code seems to behave as if
the last value</span><br style="font-size:12.8px"><span style="font-size:12.8px">is different from the other 3, supposed equal values.</span><br style="font-size:12.8px"><span style="font-size:12.8px">I am not even sure what I am seeing in the debugger,
since most of the</span><br style="font-size:12.8px"><span style="font-size:12.8px">values are optimized out (and I am not so skilled with debuggers).</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">[1] </
span><a href="
https://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/" style="text-decoration-line:none;color:rgb(66,133,244);font-size:12.8px">
https://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/</a><br style="font-
size:12.8px"><span style="font-size:12.8px">[2] </span><a href="
https://pastebin.com/embed_js/T3g560UV" style="text-decoration-line:none;color:rgb(66,133,244);font-size:12.8px">
https://pastebin.com/embed_js/T3g560UV</a><br style="font-size:12.8px"><br
style="font-size:12.8px"><span style="font-size:12.8px">Bests,</span><br style="font-size:12.8px"><span style="font-size:12.8px">Giulio</span></div>
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)