Money type

Ola Fosheim Grøstad ola.fosheim.grostad at
Fri Jan 3 18:19:24 UTC 2020

On Friday, 3 January 2020 at 17:45:44 UTC, Steven Schveighoffer 
> If tax is added on top of the total taxable cost, then a 
> per-item cost is going to be inexact anyway (some will have one 
> extra cent added due to the rounding).

Yes, although in Norway you have to give prices including VAT to 
consumers, but not to businesses where excluded VAT is the norm. 
So to get nice looking figures like "9.90" to consumers or to 
businesses you can either set the price including/excluding VAT 
and calculate the other unit doing multiplication/division.  (The 
"law" is that the VAT is added, but that is only in book keeping).

> You can create systems that have rules for how to deal with 
> imprecision, but you need to base it on types that are easy to 
> predict and don't require IEEE experts to understand.

In that case you have to rule out fixed point and you'll have to 
settle for a large base 10 type.

I think that is going a bit far.  In my book it all depends on 
the situation, and the programmer is obviously part of that, but 
so is the platform (e.g. javascript), laws and regulations, 
whether it is for estimates or invoices, if it is used for 
accounting or sales pitch, etc etc.

More information about the Digitalmars-d mailing list