Edited the post to add a "floating point isn’t bad or random" section because I really did not want people to take away "floating point is bad". Floating point is amazing! It's just solving an inherently very hard problem.

@b0rk Maybe it's useful to mention what that problem is? The way I phrase it is that FP is intended for computations where you care about relative accuracy.

@robryk @b0rk My take is that floating point is for when you want to do non-integer arithmetic fast, without using much memory, and you're willing to trade off some accuracy to do that. And that it used to be necessary for many everyday computations when computers were much slower and had kilobytes of RAM, but these days should really only be used for special purposes like 3D graphics and neural net simulations where performance is still critical.

@mathew @robryk @b0rk floating point is the workhorse of all scientific and engineering computing. And for good reason; it didn't come out of nowhere, but is the fruit of several decades of figuring out how to do numerical computing using machines.

@jannem @robryk @b0rk Yep. Specialized fields where speed is important still use floating point, and have worked out how to deal with its eccentricities.

Follow

@mathew @jannem @b0rk

I don't see any alternative. When I do computations on paper that involve values measured with some uncertainty, I essentially use base 10 floating point.

_If you're in the right situation_ those eccentricities do not matter. It doesn't matter to me that I can't represent exactly 2/3 in decimal floating point -- the value I'm going to e.g. multiply that 2/3 with in a few moments anyway comes from a measurement with some relative error, so I can just choose appropriately accurate representation of 2/3.

@robryk @jannem @b0rk Support for fractions is also woefully lacking from most programming languages.

Ruby is one of the examples that has them:
irb(main):006:0> 4/5r * 2/3r
=> (8/15)

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.