[dead]
Re:Vercel, formerly Zeit, raises $21M Series A
by WJW on Tuesday April 21, 2020 @08:08AM
(#22934169)
0.1 + 0.2 == 0.3 returns false in all the interpreters I have installed locally (Ruby, Python, NodeJS and Haskell), and you can't with a straight face pretend that Haskells type system is not strict enough.
Because I was curious, I tested it out with C# on repl.it and behold, 0.1 + 0.2 == 0.3 returns false in C# as well: https://repl.it/repls/AdoredValidVirtualmachines. Not very surprising of course, since that "error" is a result of the IEEE floating point spec and not of any language.
Re:Vercel, formerly Zeit, raises $21M Series A
by Davertron on Tuesday April 21, 2020 @08:19AM
(#22934237)
Thank you, I'm so sick of this being used as an example of why JavaScript is bad...
Re:Vercel, formerly Zeit, raises $21M Series A
by covidcovidcovid on Tuesday April 21, 2020 @09:52AM
(#22934973)
If you write in C# decimal a = 0.1m; decimal b = 0.2m; var result = a + b; then you will get exactly 0.3, because decimal is a special high-precision numeric type that doesn't have such issues.
Re:Vercel, formerly Zeit, raises $21M Series A
by acdibble on Tuesday April 21, 2020 @08:06AM
(#22934155)
It's not just JavaScript with that issue...
https://0.30000000000000004.com/
Re:Vercel, formerly Zeit, raises $21M Series A
by covidcovidcovid on Tuesday April 21, 2020 @09:53AM
(#22934978)
Not if you use decimal type that is not available in JavaScript.
Re:Vercel, formerly Zeit, raises $21M Series A
by SloopJon on Tuesday April 21, 2020 @12:38PM
(#22936569)
I'm curious what you're comparing JavaScript to. Decimal is the native numeric datatype for the stored procedure language of the database I use. Otherwise, even in languages that have a decimal class in their standard library, it's usually pretty clunky to use; no better than, say, https://github.com/MikeMcl/decimal.js/ C# is perhaps the best among mainstream languages, although its implementation is a bit weird.
Re:Vercel, formerly Zeit, raises $21M Series A
by covidcovidcovid on Tuesday April 21, 2020 @01:15PM
(#22936971)
What is clunky about decimal type? You declare a decimal variable and then use it exactly like any other numeric type. Here is an example: https://dotnetfiddle.net/jjJHA6