3 ms·
> I don't think that's correct, absent some no-true-scotsman gymnastics. Yeah, I think OP's claim is not valid. Even .NET provides System.Decimal, which by des
by chipdart 2y ago
> I don't think that's correct, absent some no-true-scotsman gymnastics.
Yeah, I think OP's claim is not valid. Even .NET provides System.Decimal, which by design and explicitly mentions financial calculations.
Taken from the intro docs:
https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-decimal https://learn.microsoft.com/en-us/dotnet/fundamentals/runtim...
> The Decimal value type is appropriate for financial calculations that require large numbers of significant integral and fractional digits and no round-off errors.
- nostrademons 2y agoThis is often not what you want with monetary calculations. You want the rounding: you'll be making a payment of $25.86, not $25.85714285714... But you just want to make sure that the next payment is $25.85, not $25.86 or $25.857142851, and that all 7 payments together equal $181 and not $181.02.
- deleted 2y ago[deleted]
- explorigin 2y agoI can't speak for C# but the Python Decimal type handle significant figures correctly. > The decimal module incorporates a notion of significant places so that 1.30 + 1.20 is 2.50. The trailing zero is kept to indicate significance. This is the customary presentation for monetary applications. For multiplication, the “schoolbook” approach uses all the figures in the multiplicands. For instance, 1.3 * 1.2 gives 1.56 while 1.30 * 1.20 gives 1.5600.
- eriksencosta 2y agoLanguages indeed have support for currencies and decimal numbers. My implementation is based on Fowler's Money pattern. The Money object is thus a value object representing a monetary amount in a given currency. https://martinfowler.com/eaaCatalog/money.html https://martinfowler.com/eaaCatalog/money.html