Skip to content

Don't use floats #2

@brenobaptista

Description

@brenobaptista

Float operations are not precise (0.1+0.2=0.30000000000000004), so don't use them for monetary calculations.

There are two workarounds to this:

1 (simple but not scalable) - convert the floats to integers, do the operations, then convert them back to floats

2 (complex but scalable) - create a class that handles the data (idea by Martin Fowler). There are a few libraries to do that, like Dinero.js

I think loanAmount and apr are the two variables that can be floats.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions