News for hackers. Stuff that matters.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by regularfry on Tuesday May 09, 2023 @04:52PM (#35880216)
I've always held that the numbers themselves are perfectly precise. It's the operations that don't do what you expect.

Of course, that observation may be more or less useful, depending on circumstances.

Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by ChainOfFools on Tuesday May 09, 2023 @06:33PM (#35881216)
Somewhere in the distant past a second grade me is staring at his math homework and fuming over the frustratingly ambiguous meaning of the minus sign. Is it an operator? A property? Both?
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by thr-nrg on Tuesday May 09, 2023 @06:49PM (#35881361)
Math notation is to mathematics as poetry is to English.

The only acceptable grammar for math is s-expressions.

Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by Conscat on Tuesday May 09, 2023 @11:22PM (#35883269)
Well, idiomatic C++23 is an acceptable math notation too.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by thr-nrg on Wednesday May 10, 2023 @05:09AM (#35885265)
No it isn't. S-expressions are the simplest serialisation or trees. Trees are the simplest grammar that can encode mathematical expressions. C++ by comparison is as usable as doing cube roots using roman numerals.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by Dylan16807 on Tuesday May 09, 2023 @07:45PM (#35881806)
It's only ambiguous if you think it does two things. I say it does one thing.

-4 always removes 4, whether or not there is a number to the left.

Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by ChainOfFools on Tuesday May 09, 2023 @07:54PM (#35881878)
The problem arises with the way that this stuff is taught at a very elementary level, which then needs to be thrown away and relearned long after intuition and habits have formed around the old model. As an adult my reasoning is that it does indeed only do one thing: negation. it doesn't take anything away at all, if anything it actually adds information. Negating a four doesn't take it away, it just specifies a different (inverted) mapping of a given value with respect to zero. And this is still a very naive take, as someone with no background in number theory. But it's much more useful than say, Billy has four apples, he gives three to Mary, etc.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by Qem on Tuesday May 09, 2023 @08:32PM (#35882152)
We could make the minus sign go away if we adopted a balanced base (e.g. balanced ternary), that has both negative and positive digits. That way, just looking at the digits would make evident if a number is positive or negative, without any need for a minus sign.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by RhysU on Wednesday May 10, 2023 @07:43AM (#35886044)
I love that such systems were built once: https://www.wikipedia.org/wiki/Setun
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by karpierz on Tuesday May 09, 2023 @07:32PM (#35881729)
How do you define numbers in a meaningful way without involving operators?

Without operators, all you have is a set of objects which you can't tell apart.

Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by regularfry on Wednesday May 10, 2023 @07:39AM (#35886016)
Oh, you have operators. They're just imprecise.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by addaon on Tuesday May 09, 2023 @08:09PM (#35882007)
> I've always held that the numbers themselves are perfectly precise. It's the operations that don't do what you expect.

I think that this is an oversimplification, and misses a key point.

Floating point numbers can be interpreted in (at least) two distinct ways.

In one use model, floating point numbers allow a sparse representation of selected points on the (extended) real number line. In this model, the numbers themselves are perfectly precise, and the basic operations do exactly what you'd expect -- but because the result of the expected real-number operation may not be one of the selected representable points, each operation is potentially paired with a second, implicit, rounding operation, and the consequences of the cumulative effects of this rounding operation take some thought.

This first model is often comfortable for those who have done low-level numerical program with sized integers, which are likewise a selected sparse representation of selected points on the integer line. While rounding comes up in fewer operations here, and is simpler, wrap-around becomes an issue.

However, a second model of floating point numbers is that each possible bit sequence represents an /interval/ on the (extended) real number line. In versions of this model, while the set of representable intervals is still very restricted, every point on the real number line falls into a representable interval, which is a property that sometimes eases (and sometimes seems to ease) analysis. In exchange, the operations are much more complex, and their limitations are much more obvious -- in particular, not only can no disjoint intervals be represented, but for any given point on the real line only one interval that contains it is representable -- there's no way to represent intervals of different sizes containing (some of) the same points.

This second model is what people are mostly thinking of when they say that floating point arithmetic is "not precise." In particular, both the inputs and outputs of operations have imprecise interpretations -- that is, the input interval contains infinitely many indistinguishable points, and the output interval contains infinitely many indistinguishable points, even if a real number equivalent of the problem would have a single number in the desired range.

When extended to true interval arithmetic, the second model can be very useful for understanding error propagation and uncertainty, but sadly this is rarely done.

Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by adgjlsfhk1 on Wednesday May 10, 2023 @01:12AM (#35883868)
the problem is the second interpretation is wrong. for example, exp(x) would give a higher value than it does since the average value of the exponent of a range is higher than the exponent of it's center.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by regularfry on Wednesday May 10, 2023 @07:38AM (#35886009)
Yep. For a sequence of operations to work on a range you do actually need to track both ends of the range, not just one of them. Otherwise what you end up implicitly doing is flipping lossily between a range interpretation and a point interpretation and back again.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by kragen on Wednesday May 10, 2023 @01:30AM (#35883974)
the second model is wishful thinking; the first model describes how ieee-784 arithmetic actually works

as you point out, the second model can be implemented