Rounding Standards - Financial Calculations

后端 未结 5 1315
时光说笑
时光说笑 2021-01-30 10:44

I am curious about the existence of any \"rounding\" standards\" when it comes to the calculation of financial data. My initial thoughts are to perform rounding only when the da

5条回答
  •  时光说笑
    2021-01-30 11:38

    The first and most important rule: use a decimal data type, never ever binary floating-point types.

    When exactly rounding should be performed can be mandated by regulations, such as the conversion between the Euro and national currencies it replaced.

    If there are no such rules, I'd do all calculations with high precision, and round only for presentation, i.e. not use rounded values for further calculations. This should yield the best overall precision.

提交回复
热议问题