5 ms·
Fair enough. One thing along similar lines that I've always hated to see is when the floating-point type in a programming language is called "real".
by bunderbunder 7y ago
Fair enough.
One thing along similar lines that I've always hated to see is when the floating-point type in a programming language is called "real".
- tomxor 7y agohaha, yes it's a terrible name, such arrogance to suggest fitting infinite things into a very finite thing. In fact they couldn't even call it rational, because even after the precision limitation it's a subset of rationals (where representation error comes from due to base)... Inigo Quilez cam up with a really interesting way around this limitation where numbers are encoded with a numerator and denominator, he called "floating bar", this essentially does not have representation error, but it will likely hit precision errors sooner or at least in a different way (it's kinda difficult to compare directly).
- bunderbunder 7y agoYeah, that is more what I'm on about. I can accept that a computer's `int` type is not an infinite set, even if it does cause problems at the boundaries. It feels like more of a little white lie to me. Whereas, even between their minimum and maximum values, and even subject to their numeric precision, there are still so many rational numbers that an IEEE float can't represent. So it's not even a rational. Nor can it represent a single irrational number, thereby failing to capture one iota of what qualitatively distinguishes the real numbers. . . if Hacker News supported gifs, I'd be inserting one that features Mandy Patinkin right here.
- tomxor 7y agoYeah, I think this is the single aspect that everyone finds unintuitive, everyone can understand it not having infinite precision or magnitude. It's probably a very reasonable design choice if we could just know the reasoning behind it, I assume it will be mostly about practicality of performance and implementing the operators that have to work with the encoding.
- gumby 7y agoCommon Lisp has had a rational number Type since the 1980s at least, presumably inherited from MACSYMA
- romwell 7y ago>Inigo Quilez cam up with a really interesting way around this limitation where numbers are encoded with a numerator and denominator, he called floating bar Thanks for the read! More fun than the original article to my taste :) Here's the link, since Googling "floating bar" nets you very different results: http://www.iquilezles.org/www/articles/floatingbar/floatingbar.htm http://www.iquilezles.org/www/articles/floatingbar/floatingb...
- tomxor 7y agoI just remember his name, writes lots of interesting stuff :)
- romwell 7y agoI always wonder if he ever says "My name is Inigo Quilez. Prepare to learn!". My favorite post by him is where he explains that you never need to have trigonometry calls in your 3D engine. Because everyone now and then you still see "educational" article in the spirit of "learn trig to spin a cube in 3D!" :/
- tomxor 7y agoYeah, I've noticed in physics programming in other peoples code you can often come across the non-trig ways of doing things that avoid unit vectors and rooting etc (which are both elegant and efficient)... However i've never personally come across an explicit explanation or "tutorials" of these targeted at any level of programmer's vector proficiency. Instead i've always discovered them in code, and had to figure out how they work. I guess the smart people writing a lot of this stuff just assume everyone will derive them as they go. That's why we need more Inigo Quilez's :D to lay it out for us mere mortals and encourage it's use more widely.
- astrobe_ 7y agoThen you should hate integer too.
- tomxor 7y ago"integer" as a type is less offensive though, as it only has one intuitive deficiency compared the mathematical definition (finite range). Where as "real" as a type has many deficiencies... it simply does not contain irrational numbers, and it does not contain all rational numbers in 3 respects: range, precision and unrepresentable due to base2, and for integers it can represent a non-contiguous range!
- ska 7y agocountable vs. uncountable deficiencies...
- ben509 7y agoBut I can build a computer that would accept any pair of integers you sent it, add them and return the result. Granted, they'd have to be streamed over a network, in little-endian form, but unbounded integer addition is truly doable. And the restriction is implicit: you can only send it finite integers, and given finite time it will return another finite answer. You can't say the same about most real numbers, all the ones that we postulate must exist but that have infinite complexity. You can't ever construct a single one of them.
- Dylan16807 7y agoI'm not sure what your point is. It's impossible to ask the computer to store those numbers, so why does it matter whether they can be stored? Or in other words: It can store all the non-computable numbers you give it. That should suffice.
- rwallace 7y agoThe way I see it, 'int' as a truncation of 'integer' nicely symbolizes the way the type truncates integers to a fixed number of bits. Of course any self-respecting modern language should also provide arbitrary-precision integers at least as an option.