Open nus-pe-bot opened 7 months ago
As a whole, this issue is unclear - do you have any reason as to why you believe we shouldn't round up floating point values to 2 d.p.? I am open to further clarification and discussion on this matter.
Now, allow me to give an explanation as to why our team chose to round off floating point values to 2 d.p.
Floating point values are used in our application to represent currency values (specifically, these represent the cost and sale prices of items). We wish to note that most modern currency denominations are represented with a precision of 2 d.p.
Using the example you've provided - is it sensible or practical to have 214738367.00702 dollars? Or does it make more sense to round this off to 214738367.01 dollars instead, for convenience and ease of use?
Furthermore, the rounding off of currency values to 2 d.p. increases the performance and computational efficiency of our application. As you may or may not be aware, floating point arithmetic is complicated and computationally intensive. As more decimal places are involved, the stability of floating point arithmetic operations decreases. It thus stands to reason why we choose to round off values, as it makes the floating point computation more stable.
Lastly, to reiterate what I've mentioned earlier, most currency denominations are divided into 100 sub-units (cents), and thus, have a natural precision of 2 d.p. Our choice of rounding off to 2 d.p. thus supports this fact, and improves the practicality of our application for users in most countries.
--
should float numbers be rounded up to 2 d.p??
[original: nus-cs2113-AY2324S2/pe-interim#901] [original labels: severity.Low type.FeatureFlaw]