Open kouyk opened 2 months ago
Yes, rounding off to 2 digits will actually fix this issue easily, As I am storing everything as whole number in DB. Good catch will work on it. Thanks
As I used the application more frequently, I'm starting to find edge cases where storing as whole number in DB does not seem to be able to solve the issue since the split is determined in the frontend.
The set up consists of two users, Alice (current user) and Bob in a new group.
Steps:
Splitwise is observed to randomly assign the final cent in this case, which is updated each time the transaction is updated as well.
It seems like currencies are handled as javascript floats. This is probably going to cause quite a lot of numerical instability issues. For example, I was trying to add a transaction that is $11.10 in total, then by using the exact split option, entering $5.20 for the first person results in $5.90 remaining, the calculated value is inexact $5.8999... This made it difficult to pass the verification. While there are workarounds such as splitting by shares, it doesn't solve the fundamental issues with using floats with currencies. Larger values will cause even more issues. Maybe this aspect could use some tests for such edge cases and ensure that the sums are correct.