Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Double with BigDecimal #120

Merged
merged 2 commits into from
Oct 14, 2024
Merged

Replace Double with BigDecimal #120

merged 2 commits into from
Oct 14, 2024

Conversation

mdrlzy
Copy link
Member

@mdrlzy mdrlzy commented Oct 11, 2024

Double has poor precision which can be problem when working with currencies.

0.03 - 0.02 // 0.009999999999999998
BigDecimal.valueOf(0.03) - BigDecimal.valueOf(0.02) // 0.01

return Gson().toJson(list, type)
val type = object : TypeToken<List<AmountStr>>() {}.type
val listStr = list.map { it.toStrAmount() }
return Gson().toJson(listStr, type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use Kotlin Serialization here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to use Gson as it is the Json parsing lib in our project. If use Kotlin Serialization we have to add more dependency

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there won't be much difference between kotlin serialization and gson. Considering there is less code with gson

@mdrlzy mdrlzy merged commit da477c9 into main Oct 14, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants