4 ms·
Would you say it's "odd" that popular languages (C#, Java, JavaScript/node.js/TypeScript, Python) don't have built in decimal libraries?
by MuffinFlavored 4y ago
Would you say it's "odd" that popular languages (C#, Java, JavaScript/node.js/TypeScript, Python) don't have built in decimal libraries?
- MichaelNolan 4y agoJava has BigDecimal. Python has a decimal and a fraction class. I’m assuming C# has something apart of their standard library as well. And JS/TS has third party libraries that can for arbitrary length precision math as well.
- MuffinFlavored 4y agoThank you. I had a feeling I was wrong. So just JavaScript has BigInt/BigDecimal https://stackoverflow.com/questions/16742578/bigdecimal-in-javascript https://stackoverflow.com/questions/16742578/bigdecimal-in-j..., interesting
- int_19h 4y agoC# has it as part of the language itself, with keyword for the type and a special literal syntax for it: decimal n = 123.456m;
- jacobsenscott 4y agoI don't think I would say it is odd because it isn't a type of number that is directly supported by the hardware. That said it is available in the standard library of most popular languages, and probably just a package install away for any other languages. Also, a plain integer is usually sufficient for financial calculations (just count pennies, not dollars) so in some ways I think decimal types are overused when an integer would do just fine.