News for hackers. Stuff that matters.
Re:0.30000000000000004 by chrisseaton on Tuesday December 03, 2019 @03:13AM (#21690726)
In a language like Java, all these factors are specified and fully deterministic.
Re:0.30000000000000004 by lmm on Tuesday December 03, 2019 @09:05AM (#21692303)
False. Floating-point arithmetic in Java is generally nondeterministic. You will notice that the strictfp keyword exists and is off by default.
Re:0.30000000000000004 by chrisseaton on Tuesday December 03, 2019 @09:32AM (#21692504)
It's not false - strictfp mandates deterministic FP. If you use that your program will always run all floating point calculations in exactly the same way, full stop.

Secondly, on mainstream implementations, strictfp is already documented the same as default! They're planning to remove it anyway as it's a no-op in almost all cases.

See JEP 306.

Re:0.30000000000000004 by lmm on Tuesday December 03, 2019 @05:00PM (#21697253)
> It's not false - strictfp mandates deterministic FP. If you use that your program will always run all floating point calculations in exactly the same way, full stop.

If you use it. Which is not the default. Your original claim remains false.

Re:0.30000000000000004 by lmilcin on Tuesday December 03, 2019 @04:01AM (#21690933)
It does not matter. When you are doing accounting you are supposed to be able to sum large collections of numbers and get the same result regardless of the order.

That's something FP does not provide and it makes it completely unusable for accounting.

Re:0.30000000000000004 by josefx on Wednesday December 04, 2019 @08:34AM (#21701995)
> regardless of the order.

That seems like a completely arbitrary requirement. Do accounting laws prohibit sort? Does 1 + 1 have to equal green on Tuesdays?

Re:0.30000000000000004 by lmilcin on Wednesday December 04, 2019 @08:47AM (#21702080)
It seems you have no idea what double-side accounting is.

Each operation is accounted on two opposite sides of various account in a way that always keeps sides balanced (ie. they must sum up to the same value).

When you go to your bank account, for example, you have various sums on both sides of your account. Yet when you sum them up they MUST agree or you will be crying blood and suing your bank.

Re:0.30000000000000004 by tsimionescu on Tuesday December 03, 2019 @03:56AM (#21690914)
True, that's a good point. I was thinking of C & C++, but you're right, newer languages do a much better job of specifying and controlling this behavior.

Wonder if JS does something similar or not.

Re:0.30000000000000004 by gdxhyrd on Tuesday December 03, 2019 @05:00AM (#21691185)
All major C/C++ compilers implement IEEE754. If you are telling the compiler to disregard it, that is on you.
Re:0.30000000000000004 by tsimionescu on Tuesday December 03, 2019 @05:50AM (#21691373)
It's not about IEEE754, it's about the precision that the FP co-processor offers. The results you get are correct per IEEE754, it's just that they may have even less error than required by IEEE754 in some cases. But, this is enough to make the results non-deterministic between different compilation options.

Also, changes applied to the FP co-processor by other processes on the machine could impact your process, regardless of your own compilation settings.

Re:0.30000000000000004 by chrisseaton on Tuesday December 03, 2019 @06:28AM (#21691523)
Are you talking about x87?

That's ancient history. Compilers don't use that instruction set any more in normal operation.

GCC, Java, LLVM, etc, will normally emit SSE2 in order to be standards compliant. They will only relax this if you tell them to, then it's your problem.

Re:0.30000000000000004 by tsimionescu on Tuesday December 03, 2019 @07:45AM (#21691823)
Yes, I was explicitly talking about the x87, and did mention that it has stopped being relevant for at least 10 years.

I believe there is still quite a bit of cautionary discussion of floating point numbers that was written in the age of the x87, so it's important to understand that people were not just misunderstanding IEEE754, even though their concerns are no longer applicable to modern hardware.