

Show HN: Online IEEE 754 playground - delan
https://www.azabani.com/labs/floatvis/

======
Sanddancer
This isn't IEEE 754 floating point, but rather Javascript floats. For example,
it gets (n!=0)/0 wrong by using the javascript NaN value instead of the IEEE
754 value of +-Infinity. For a playground like this, I think that it would be
interesting to show how IEEE 754 and Javascript differ -- division by zero,
the max function, etc.

Edit: I had misremembered one of the differences. Javascript does get division
by zero correct. The biggest differences are in the comparisons, Javascript
propagates NaNs more frequently.

~~~
cremno
Why do they even differ?

~~~
Sanddancer
Decisions made when javascript was being written. Certain functions were
decided to be more non-numeric than what the floating point spec called for.

------
recursive
Lack of understanding of floating point numbers is one of the most persistent
and pervasive problems in programming. Just look at Stack Overflow on any
given day. I've also helped co-workers more times than I can count on problems
that stem from not understanding how floats work.

~~~
csirac2
I was working with someone who thought _I_ was stupid for insisting on integer
or fixed-point maths for what I insisted would be a particularly troublesome
piece of functionality.

They were more experienced, convinced me I was being pedantic, and I myself
wasn't coding on that project anyway. Months later, we had to do a panic
refactor as real-world usage immediately made the app fall over.

These are the kinds of bugs I discovered as a kid writing crappy computer
games for my friends and I: "floats for everyone! This is way easier!",
followed later with: "floats are slow, and I don't understand half my bugs!".

Actually, on this project I found myself explaining several things I'd learnt
from recreational games programming. Things that you apparently don't learn in
CS (I did EE, so I wouldn't know), or a decade of doing the J2EE business
middleware dance.

~~~
planteen
It's kind of funny that in digital signal processing the situation is
sometimes the opposite. Floating point computation is seen as easier and more
accurate but much more expensive. VHDL 2008 added synthesizable reals from
demand. I've been a part of fixed point DSP on a FPGA and it really made me
appreciate both sides of the float/fixed coin.

------
kukx
If someone doesn't know what IEEE 754 is - it's "a technical standard for
floating-point computation"
[https://en.wikipedia.org/wiki/IEEE_floating_point](https://en.wikipedia.org/wiki/IEEE_floating_point)

