News for hackers. Stuff that matters.
Re:Floating Point Visually Explained by jordigh on Thursday September 28, 2017 @03:30PM (#15360026)
Okay, fine, I agree that sometimes mathematical notation is bad and we are all computer people here, not math people, so we get really scared of mathematical notation.

But is (-1)^S 1.M 2^(E-127) so bad that it required a whole blog post to explain it? Except for the "1.M" pseudo-notation to explain the mantissa with the implicit on bit, all of those symbols are found in most programming languages we use.

I don't think the value of the blog post was explaining the notation. We all knew what operations to perform when we saw it. The value seems to lie more in thinking of the exponent as the offset on the real line and the mantissa as a certain window inside that offset.

Personally, though, this still doesn't seem like a huge, deep insight to me, but maybe I'm just way too used to floating point and have forgotten how hard it was to learn this. I did learn about mantissa, exponents, and even learned how to use a log table in high school, but maybe I'm just old and had an unusual high school experience.

Re:Floating Point Visually Explained by kemerover on Thursday September 28, 2017 @03:52PM (#15360183)
I don't really understand significance of this insight easier. Floating point number is just stored in scientific notation base 2. That's it. And kids learn scientific notation in 7th grade? 8th tops. I mean, swap base 2 to base 10 in this image, and the effect changes from "woah" to "duh, obviously".
Re:Floating Point Visually Explained by coldtea on Thursday September 28, 2017 @04:08PM (#15360298)
>But is (-1)^S 1.M 2^(E-127) so bad that it required a whole blog post to explain it?

Well, for one the expression doesn't tell us anything, could as well describe alien gravity -- even if we know math. You still need to explain what S, M, and E are used for to understand it.

Re:Floating Point Visually Explained by pharrington on Thursday September 28, 2017 @06:06PM (#15361160)
S is sign. M is mantissa. E is exponent.

The only term there you might not remember from high school math is mantissa, and a search engine will precisely explain that in two sentences, in terms you do remember from high school math.

Re:Floating Point Visually Explained by kllrnohj on Thursday September 28, 2017 @07:57PM (#15361756)
> S is sign. M is mantissa. E is exponent.

That doesn't actually get you any closer to knowing what the formula means, though. You need to also define that M is unsigned & 23 bits and E is unsigned & 8 bits. And that alone still doesn't get across the resulting limitations like that precision reduces by half every time the exponent bumps. Sure you can reason about it if you devote the brainpower to applying the limitations to the formula, but it's not explained by the formula itself.

Re:Floating Point Visually Explained by pharrington on Thursday September 28, 2017 @10:51PM (#15362410)
Yes, jordigh did post, mistakenly or deliberately, an incomplete explanation of IEEE754 single precision floats. A number line with alternative labels showing an approximate mantissa and exponent for a given float is certainly one possible way to explain the application of the spec, but obviously, not only does it give less information than the specification, it is not obvious that it is a generally better explanatory tool. For example, it certainly helps Fabien, I assume it helps you and coldtea, but it leaves me completely bewildered (I know what it says, but on it's own, I'm completely lost as to why).

edit: jordigh, not coldtea, first brought up the formula in his argument

Re:Floating Point Visually Explained by coldtea on Friday September 29, 2017 @04:00AM (#15363535)
>not only does it give less information than the specification

That's generally considered a plus (if not a sine qua non) for a simplified explanation, and the larger the specification, the bigger plus.

Else, one might as well read the 100s of pages of specs.

Re:Floating Point Visually Explained by pharrington on Wednesday October 04, 2017 @03:32PM (#15403737)
Re:Floating Point Visually Explained by jdnier on Friday September 29, 2017 @09:23AM (#15364988)
A search engine will also show that the use of the word "mantissa" in relation to floating point numbers is discouraged in favor of "significand".

"it is an abuse of terminology to call the fraction part a mantissa, since this concept has quite a different meaning in connection with logarithms"[1] –DEK

[1] https://en.wikipedia.org/wiki/Significand#Use_of_.22mantissa...

Re:Floating Point Visually Explained by tpeo on Thursday September 28, 2017 @04:33PM (#15360480)
How is this issue unique to strings? Nobody can look at a random graph and know what it stands for either. Otherwise there would be no need for labeled axes. You still need to explain what is it that we're looking at

This isn't to say that visualizations aren't useful, of course.

Re:Floating Point Visually Explained by coldtea on Thursday September 28, 2017 @04:46PM (#15360579)
>How is this issue unique to strings?

Who said anything about strings?

>Nobody can look at a random graph and know what it stands for either.

Well, the parent wrote: "is (-1)^S 1.M 2^(E-127) so bad that it required a whole blog post to explain it?".

And the answer is, yes it is.

We can look at y = 2*x + 5 and understand it immediately. Sums, limits, and lots of other equations too.

Floating point though is an encoding/representation scheme, so it needs more than the mere equation to be understood. I don't just want to know I replace three numbers and do a calculation, I need to know what these numbers are supposed to represent.

Re:Floating Point Visually Explained by tpeo on Thursday September 28, 2017 @05:09PM (#15360735)
I've mentioned strings, and so did you now.

What I don't understand is what's supposed to be uniquely puzzling about strings. Maybe I'm under the influence of the submission, because the guy said he had an allergy for notation. But even after putting a floating point expression in analogy with some geometrical constructs, the whole thing could still be a model of alien gravity, because neither the expression nor the geometric figures carry any inherent meaning in themselves. The only reason why we know that it is in fact just a pure representation of how to approximate real numbers is because the post itself tells us so.

Re:Floating Point Visually Explained by chrisoverzero on Thursday September 28, 2017 @06:16PM (#15361217)
“Who said anything about {x}?” is an idiomatic equivalent to “Why did you bring up {x} unprompted?”

I think you're trying to say that unlabeled formulas are no better or worse than unlabeled graphs and the like, but calling a formula a “string” is muddling it up. (If that is what you meant.) Because we're talking about floating-point data types, people are likely to think of the string data type.

Re:Floating Point Visually Explained by JadeNB on Thursday September 28, 2017 @05:28PM (#15360891)
> But is (-1)^S 1.M 2^(E-127) so bad that it required a whole blog post to explain it?

What is the value of this question? If you don't need a blog post to understand it, then don't read it; no harm was done. Obviously the author felt that there was enough potential for confusion that an explanation might be needed, and other commenters here have appreciated it. That's good for some people and harm for no-one, which seems a pretty clear net win.

Re:Floating Point Visually Explained by jordigh on Thursday September 28, 2017 @06:24PM (#15361279)
Because I get frustrated with people. I feel like they refuse to even attempt to understand. They say to themselves "I'm a visual learner" (everyone is) or they seek solace in groups when mathematical notation is difficult to understand. It's ok if I don't understand this, and I don't even have to try, because lots of other people don't get it either!

If even an idiot like me can understand mathematical notation, anyone can. In particular, if you're able to understand code, you can understand mathematics. I get frustrated with the mental barriers people set up for themselves when learning mathematics.

I think it may even be cultural. I have heard that in China, for example, they don't have this aversion to anything that looks mathematical.

Re:Floating Point Visually Explained by dahart on Thursday September 28, 2017 @09:17PM (#15362069)
> Because I get frustrated with people. I feel like they refuse to even attempt to understand.

Many people do refuse to understand. My parents & grandparents do that about anything computer related at all, not to mention math. Lots of people, especially guitar players, avoid learning music notation. Most people gloss over anything in a foreign or technical vocabulary.

I agree with you, and I get frustrated too, and I like to dig into mathy stuff, and I also find myself glossing over things and refusing to "get it" only to discover later it wasn't that hard.

So: does it help to get frustrated? Aside from expressing incredulity, what can you do to help someone more easily understand, or get motivated to understand?

It seems like for at least a subset of people, calling it "easy" and making pictures really truly does help them understand it, and/or spend the time being willing to understand it. What's wrong with that?

> I think it may even be cultural.

It might. I'd buy that Asian students get more math and have a slightly lower aversion in general. But I also know older Asians that refuse to learn simple computer concepts exactly the same way my parents do, so on that anecdata alone, I'd speculate that refusing to learn things that seem foreign or technical is part of the human condition. I'd even guess that this is an evolutionary advantage, that our brains actively avoid hard to understand things because it uses too many of our limited cognitive resources.

Re:Floating Point Visually Explained by JadeNB on Thursday September 28, 2017 @09:53PM (#15362200)
> Because I get frustrated with people. I feel like they refuse to even attempt to understand. They say to themselves "I'm a visual learner" (everyone is) or they seek solace in groups when mathematical notation is difficult to understand. It's ok if I don't understand this, and I don't even have to try, because lots of other people don't get it either!

But surely attempting to convince someone who is afraid to learn a given piece of mathematics that it is actually within his or her comprehension is a good thing, not a bad? One need not convince a die-hard visual learner that he or she should give up learning that way, only that he or she can, and probably should, strive to learn how to convert mathematics into a more visual form?

(EDIT: I just noticed that dahart (https://news.ycombinator.com/item?id=15362069) said much the same, and probably better.)

Incidentally, I think that I disagree with the statement that everyone is a visual learner. Without getting into the technical meaning of the term, if there is one, I believe that I don't learn by picturing images the way that I think people who say that they are visual learners believe that they are learning.

Re:Floating Point Visually Explained by jordigh on Thursday September 28, 2017 @10:14PM (#15362281)
I'm quite certain you can understand a histogram a lot better than a long list of numbers, that a continuous function will make more sense if you're able to look at its graph, that you've doodled or scrawled on a board some sort of diagram to help you understand something.

We're not digital computers. We have a well-developed visual cortex and we have to use it in order to learn.

Re:Floating Point Visually Explained by kllrnohj on Thursday September 28, 2017 @07:52PM (#15361739)
(-1)^S 1.M 2^(E-127) is the concept not the implementation and the implementation is the important part, especially as a programmer. The blog is mostly about the details. How the bits are allocated, how they influence precision, etc...

And exactly none of that is included in "(-1)^S 1.M 2^(E-127)"

Re:Floating Point Visually Explained by nv-vn on Thursday September 28, 2017 @08:40PM (#15361936)
But that's not what the blog post is about. Every other explanation of floating point numbers describes how bits are allocated. The visual part of this article is a drawing of the window and offset thing. Which in this case, is exactly what the expression is saying.
Re:Floating Point Visually Explained by badsectoracula on Thursday September 28, 2017 @04:32PM (#15360478)
Some of us are visual thinkers and understand things easier if there are images attached :-). Personally i think almost completely in images so i'd have to somehow visualize something to understand it :-P someone doing it for me helps immensely.

Of course i can also think more abstract but it feels as if i'm trying to send megabytes of data to another city through TCP/IP with one byte per send().

Re:Floating Point Visually Explained by jordigh on Thursday September 28, 2017 @06:26PM (#15361297)
Everyone is a visual learner but everyone can also understand a simple arithmetic expression. Everyone thinks almost completely in images. The only difference is that mathematicians have had more practice learning how to transform expressions into visual images. It's a bit like looking at sheet music and being able to hum it in your head.

Learning how to read sheet music isn't something that shouldn't even be attempted because you're an "auditory learner". I also think that spending a little extra effort to learn how to read an arithmetic expression is worthwhile and a skill we should foster in society.

Re:Floating Point Visually Explained by thethirdone on Thursday September 28, 2017 @08:51PM (#15361978)
>Everyone is a visual learner but everyone can also understand a simple arithmetic expression. Everyone thinks almost completely in images.

I think it is hard to separate your experience from the collective here. Much of the time I am working on math or programming, I don't think in images; I am just manipulating symbols in a patterned fashion that I have already convinced myself is sound (in a logic sense).

I definitely have never thought about floating point as anything other than binary scientific notation. I am quite comfortable with the understanding of exponent, significand, and sign.

Re:Floating Point Visually Explained by jordigh on Thursday September 28, 2017 @10:09PM (#15362252)
You've never drawn a linked list? A Venn diagram to think about your logical sets? A Hasse diagram for showing set inclusion? A function to see its growth? Never visualised numbers as being on a real line, with in-betweenness properties?

The visual cortex is one of the most developed part of our brains. Even blind people use it for mathematics:

https://www.newscientist.com/article/2106215-blind-people-us...

Even when you're doing symbol pushing "blindly", you're still using visual skills to place symbols, different fonts, you align variables, superscripts, subscripts. There's a certain geometry to mathematical notation itself.

Re:Floating Point Visually Explained by thethirdone on Thursday September 28, 2017 @11:13PM (#15362484)
> You've never drawn a linked list? A Venn diagram to think about your logical sets? A Hasse diagram for showing set inclusion? A function to see its growth? Never visualised numbers as being on a real line, with in-betweenness properties?

I never said that I don't visualize things. Just that it isn't the only (or main) way that I think about things.

By all means, methods of visualization can be very powerful. Designing different ways to visualize things can make more ideas easily accessible. Many things are also illuminated by logical proofs, sound visualizations (for lack of a better word), or narrative.

I think it is hard to extrapolate from a single experience what the best way to understand is for most people. You may be a very visual learner, and not realize that many other people don't gain as much from visualizations as you do.

> Even when you're doing symbol pushing "blindly", you're still using visual skills to place symbols, different fonts, you align variables, superscripts, subscripts. There's a certain geometry to mathematical notation itself.

The particular symbols and syntax matters little. I certainly am not considering different fonts when I work things out. Often manipulations I am doing are only in my head and don't have a concrete image until I need to write it down.

Re:Floating Point Visually Explained by noobermin on Saturday September 30, 2017 @11:08PM (#15376150)
I'll step in here. I've met people who are visual like me, and do math using their visual thinking. For me, algebra and such is like tetris or a legos but with symbols. To this day, when I do algebra in my head, it involves visualizing symbols as if they are on a page and manipulating that picture.

Others however are not visual, but yet they can do algebra fine using something like logical rules, and to be honest, often tend to be more accurate with it. It sounds like you're one of those people, so it's unfair for what the above poster said regarding everyone being "visual". I think it's not really a matter of ability, it's more about what methods people prefer and some people just don't prefer visualization.

Funny side story: I think I can do the logical thing but it isn't my usual modus operandi, and I had to work on sharpening my "logical" side. I remember when I was in particle physics, and my office mate was so good at the algebra in QFT class and always very accurate. I on the other hand made frequently many little errors, but I'd always be able to "see the forest from the trees." I remember him once showing me the correct way to derive some transition amplitude that was in the homework, and just seeing it for the first time, I said "ah, that reduces to 1 + blah" because I could see that immediately; while he hadn't realized that even after working on it for a couple of hours. I think both types of people (left and right brain I guess) sort of complement each other in research, and we both have to approach math in our own ways.

Re:Floating Point Visually Explained by 1_player on Thursday September 28, 2017 @11:57PM (#15362628)
The value of the post is that, yes, I could understand the mathematical notation, but I never had the need to dive into how floating point numbers actually work.

Now it's on HN in an accessible format, and now I know how IEEE 754 works, and I've made an intuitive mental model of it thanks to Fabien's great teaching skills.

Math notation is a compact representation of a concept, not a way to _explain_ it.

There's no need to be condescending.