Hacker News new | ask | show | jobs
by svat 1467 days ago
Whether or not that's true, you can remove "beginning" from my statement as it's not necessary (done, just edited, thanks): most programmers, most of the time, don't need the speed of floating-point everywhere (compared to fixed-point/scaled integers, or rationals, or interval arithmetic, or whatever), and when they do, the language could let them easily opt into it with a declaration like "use float" or whatever.
1 comments

Every option here has tradeoffs and drawbacks: fixed point arithmetic suffers from a very limited precision range, rationals aren't even the same number set, cauchy sequences are precise but comparatively very slow… there's no one size fits all solution that's right in every circumstance.

Except, of course, at lower levels of abstraction - where IEEE floats are what the hardware implements. Lower level languages use 8-, 16-, 32-bit integers, they use IEEE floats and doubles, and they make these choices for pretty solid reasons.

Higher level languages make different choices (arbitrary precision integers are common in interpreted languages, eg). Libraries support all kinds of options up and down the stack.

Of course, but low-level languages call their floats...floats. Certain higher-level languages often call them numbers or decimals, which is why this confusion happens in the first place. It's like if a language had uint8 but called it Integer - yes, there are many uses for uint8, but there are also many cades where it's the wrong thing to use and it shouldn't be possible to use it accidentally.
> rationals aren't even the same number set

In what way are rationals not the same number set? In the strictest sense basically none of the proposed versions have the same number set, but in a broad sense, they all represent a useful subset of rationals, right?

In a broad sense, sure.
Could you elaborate what your intended meaning was? It felt to me like you were singeling out 'rationals' as not being the same number set. Maybe we also think of something different when talking about 'rationals'?

Maybe I also missed something obvious, so I'd like to satisfy my curiosity!

I meant that rationals are a subset of the reals, and while floats are also a subset of exact reals a "typical" fixed bitwidth implementation will have a significantly greater range in floats than rationals.

I don't know that it's necessarily as significant a difference as I'd first considered it to be, though.

You can't do trigonometry on the rationals, which would prevent any games, graphics software, audio mixing software etc from using the rationals.
I mean, you can, but you shouldn't. I don't think anyone is arguing that any representation is suitable for all usecases or that ieee754 should not be available in programming languages.

Also, I think I'm too tired by now, I get confused too much between the rationals as the rational numbers \mathbb{Q} and the rationals as an implementation of rational numbers using a quotient of two integers.