Consider a scenario where you are required to store a large number of decimal values with high precision for a financial application. Which data type would be preferable and why?

  • BigDecimal
  • double
  • float
  • long
In a financial application, precision is crucial. The double data type can store decimal values but may not provide the necessary precision due to its limited number of significant digits. BigDecimal is preferred in such scenarios because it offers arbitrary precision and is ideal for financial calculations where rounding errors need to be minimized. float and long do not provide the required precision for financial calculations.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *