Hacker News new | past | comments | ask | show | jobs | submit login
Floating Point Visually Explained (2017) (fabiensanglard.net)
206 points by mercer 11 months ago | hide | past | web | favorite | 17 comments

One of my favourite sites for explaining floating-point, especially the more subtle aspects, is https://www.exploringbinary.com/ . Here's a similar article from that site:


I think this explanation still makes it harder than it needs to be. Just imagine what a "floating point" number would mean in decimal: you get (say) 5 adjacent digits to play with, and you get to choose where you put the decimal place, within a limited range.

So you can represent 12345000 or 12.345 or 0.00012345.

But 12345600 rounds to 12346000, 12.3456 rounds to 12.346, and 0.000123456 rounds to 0.00012346.

This is an awesome explanation, thanks for sharing! I remember struggling mightily in college to understand Floating Point, and my professor never offered anything other than the mathematical formula explanation. That never really helped me understand how the computer is actually dealing with these numbers, but this step-by-step explanation really clicked.

Intel's floating point coprocessor may have been out of reach for most people in the early 90's, but there were clones available. My 386 had a Cyrix I believe.

> My 386 had a Cyrix I believe.

Yup... and as I recall, it was a must have for MS flight sim and Falcon 3!

nope, ms sim didnt use fpu, falcon 3 had a separate, optional "realistic" hi-fidelity flight model that used fpu, but it was pretty broken http://simhq.com/forum/ubbthreads.php/topics/3803136/re-falc...

I don't understand how the pictures help. The core formula is compact, but that doesn't make it bad. A few sentences of explanation is great for people who haven't learned standard high-school-level math notation or who want a walkthrough as a refresher (so thanks tonthr author for writing it down ), but refusing to learn math notation is going to make learning every math concept harder, penny wise and pound foolish. I don't see how this blog post/book chapter's explanation is novel as it claims to be, or why every other explanation of floating point is supposedly poor. I suspect it's just a matter of learning concepts requires thinking, so thrilled author jotted notes while he was thinking, and misattributed his progress to the specific visuals and no to the process of thinking about the formula.

The hard part of floating point isn't the representation of numbers, it's how to perform arithmetic with rounding/truncation in the specified way (and why the specified way is preferred). The blog post doesn't touch on that at all.

Personally, I might be able to convert a number to floating point using the formula, but it's not easy to grasp why. The visual explanation really helps with that.

Being able to read maths doesn't automatically mean that it is the best way to present an explanation of something.

Any mathematical instruction I have found helpful has had a big emphasis on building “intuition“. This post was the first explanation I encountered that explained floating point encoding in a way that was immediately relatable and understandable to me. There are multiple ways to describe a thing, different people have different relationships to a thing which may make some descriptions more well-suited than others, and different people have different goals.

Some might be mistaken this post is from fabrice bellard just like me, it it not. The web address might be a little bit confusing. This is not a post by fabrice bellard the guy who initiated ffmpeg project among many others.

My son and I have been trying to understand floating point numbers with almost no success, since it's usually explained with arcane mathematical symbols that neither of us understand. This page is brilliant and I'm going to show this to him, after editing the hilarious image with the owl. Why is profanity necessary to convey intensity? It's 2019, surely we have better ways of doing so by now.

> Why is profanity necessary to convey intensity?

It's not necessary, it's just funny. The owl picture is a meme borrowed from the internet to make the same point you did ... that it feels like math notation skips over the how.

FWIW, spending time in a floating point calculator can be very enlightening. I use this page all the time https://www.h-schmidt.net/FloatConverter/IEEE754.html

A great exercise to try with your son: try numbers of various magnitudes and see what a 1-bit change does to the decimal value. For example, try the earth's radius in meters and determine the FP32 precision in meters at the surface of the earth.

Serious question - why get so bothered by it? If he's old enough to be thinking about floating point numbers, he's definitely heard the word, and it's not especially gratuitous in this instance. Might be a good opportunity to discuss how word choice is dependent on context.

> Serious question - why get so bothered by it?

Same reason why many people refuse to visit nude beaches despite others not seeing any issue in said these beaches: personal values and principles.

The owl photo has been going around the internet for at least 15 years now.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact