4 ms·
I was going to reply that I thought the point of the video/tweet is that JS does choose floating point by default while others don't. But I stand corrected, C#
by knocte 7y ago
I was going to reply that I thought the point of the video/tweet is that JS does choose floating point by default while others don't. But I stand corrected, C# default sucks too: it uses the double type!
And here I thought that by using F# I would even be protected from this shit but unfortunately it has the same problem... Performance should be opt-in! (favouring correctness over it) :facepalm:
Thanks
- wruza 7y agoFirst you should state the correctness level you need. 0.2? 1/7? sqrt(2)+pi? int n=0, n<inf, sum(1/n^3)?
- sasmithjr 7y agoLook at the decimal type; it's less performant, but you'll avoid floating point issues. https://docs.microsoft.com/en-us/dotnet/api/system.decimal?view=netcore-3.1 https://docs.microsoft.com/en-us/dotnet/api/system.decimal?v...
- ygra 7y agodecimal is still floating-point, just decimal floating-point instead of binary. Things like 1/3 can still not be represented exactly. It's just that for values given in base 10 there's no transformation of the representation and 0.3 remains exactly 0.3.
- knocte 7y agoYes I know the decimal type and it's what I use in all my code, I just thought the default would be something with more precision than double/float even if not decimal.
- gameswithgo 7y agoI'm not sure you appreciate how much performance would be lost...