On Friday, 20 May 2016 at 06:12:44 UTC, Walter Bright wrote:
On 5/19/2016 1:26 PM, Timon Gehr wrote:
Those two lines producing different results is unexpected,
because you are
explicitly saying that y is a double, and the first line also
does implicit
rounding (probably -- on all compilers and targets that will
be relevant in the
near future -- to double).
> [...]
It's obviously bad language design on multiple levels.
Floating point semantics simply are not that simple, on any
compiler, language or hardware. I recommend reading what the
C/C++ Standards say about it, and look at the plethora of
compiler switches for VC++/g++/clang++.
The people who design these things are not fools, and there are
good reasons for the way things are.
Sorry, I don't agree.
Let me cite Prof. John L Gustafson from his Book "The End of
Error" (it's worth reading):
---
The lesson taught by all these attempts at clever hidden
scratchpad work is that computer users want *consistent* answers,
and want to be *permitted the trade-of between speed and
accuracy* depending on the situation. There is a subtle arrogance
in any computer system that takes the position "You asked for a
quick, cheap, approximate calculation, but I know what is good
for you and will instead do a better job even if it takes more
time and storage and energy and gives you a different answer.
You're welcome."
---