4 ms·
> Key data structures built-in Yet a decimal data type is missing.
by ciupicri 11y ago
> Key data structures built-in
Yet a decimal data type is missing.
- AnimalMuppet 11y agoWhy do you consider that a key data structure? (It may be key for your application, but should it really be key for the language as a whole?)
- ciupicri 11y agoSome scientific and accounting software require it. Python has a decimal data type [1]. [1]: https://docs.python.org/3/library/decimal.html https://docs.python.org/3/library/decimal.html
- AnimalMuppet 11y agoSure. But that doesn't make it "key" in the sense that, say, lists and maps are.
- dragonwriter 11y ago> Sure. But that doesn't make it "key" in the sense that, say, lists and maps are. No, its more like "key" in the way that ints are. Well, not quite -- less than ints, but more than floats.
- AnimalMuppet 11y agoYou think that, across computing in general, decimal data types are used more than floats are? I am extremely skeptical. (Or do you have data?)
- dragonwriter 11y agoNo, I'm not saying they are used more often, but they are more important in major application domains. Floats are used more often, but often not because they are domain-appropriate, often as a premature optimization, or as a matter of developer convenience because many major tools (languages and libraries) make float use more convenient. Exact rationals are in a similar situation.
- kazinator 11y agoDecimals have a limited application. They basically just pander to the need to have the machine conform to some hokey pencil-and-paper arithmetic rules remotely linked to the number of fingers on two hands.
- dragonwriter 11y ago> Why do you consider that a key data structure? In real world applications, it is one of the more essential non-collection types.
- Shorel 11y agoIt's not the definitive default number only because performance reasons and because of C influence in language design. If most languages had Decimals, I am sure only C/C++/Java diehards would use ints/floats instead. In fact most modern scripted languages should have them. Regarding go, as it is a relatively new language, and having to interact with databases, with Decimal being a fundamental SQL type, yes, it should have Decimal.
- kazinator 11y agoFloats are not for C/C++/Java diehards but for rather science, engineering, signal processing, financial modeling, computer graphics ...