3 ms·
The "e" notation is just a shorthand for multiplying by a power of ten. I was kinda surprised when the article stated that "5.23e5" wasn't treated the same as a
by ryebit 9y ago
The "e" notation is just a shorthand for multiplying by a power of ten. I was kinda surprised when the article stated that "5.23e5" wasn't treated the same as as "5.23 * 10 * * 5". Mathematically, rational to an integer power is always rational. This strikes me more as a half-measure that can cause surprise and unpredictability.
edit: can't get double-asterisk to get through HN's markup :(
- grondilu 9y agoFine, but then how do you suggest one should write floating point literal values? PS. I guess there is the "f" suffix as in C++. Well, for some reason that's not what Perl 6 decided. I, for one, think it's simple enough to use the "e" notation. If you want to write a Rat with a power of ten, you can always literally write say 1.2*10**3
- iainmerrick 9y ago"f" on the end, like floats in C?
- ryebit 9y agoI don't have a ready obvious alternative (though I do see others suggested an "f" suffix). The lack of alternative was sort of my point... language design is tricky, and small features in one place can paint you into a corner when implementing another. Establishing the right dynamic tension between those features (and the parser, and the VM, and the user's mental model) definitely makes language design one of the high arts in the computer world. I'm not even saying this was the wrong decision; just that it causing a surprising deviation from how numeric literals behave in other languages. But Perl's goal has always seemed to me to be less about creating a rigorous language with well defined types that map to the low level; and more about creating an expressive feeling (to humans) language, where fundamental differences in type were merely an implementation detail. So I'm not surprised that it deviates from the norm in some interesting ways; I'm just not sure if I personally like the feel when I try to speak it :) ... but I might think to close to the metal to be the target audience.