Money type

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Thu Jan 2 18:26:25 UTC 2020


On Thursday, 2 January 2020 at 18:20:38 UTC, Ola Fosheim Grøstad 
wrote:
> E.g. to get 3% of 123 cents: (3*123.0)/100

Whoops, too quick, that won't work.

You need to set the rounding mode first and then do the 
truncating.  E.g. you can do the same calculation twice with 
round up/round down and do basic rounding. If you get the same 
result, then it is right. But easy to make mistakes... like I 
just demonstrated.. :-P




More information about the Digitalmars-d mailing list