Skip to content

The "Floating-Point Phantom" #3

@sengardeep

Description

@sengardeep

Problem

The system is experiencing small but significant floating-point precision errors when handling currency values.
Because money is currently stored as JavaScript floating-point numbers, tiny fractions (e.g., $0.0000000004) are being lost or rounded incorrectly during calculations. Over time, this can lead to disappearing or inconsistent balances.

Points: 20

Steps to Reproduce

  1. Perform multiple small transfers or operations that involve decimal values.
  2. Inspect the resulting wallet balance in the database.
  3. Notice:
    • Tiny fractions of currency disappear or accumulate incorrectly.
    • Balances drift due to floating-point rounding issues.

Expected Behavior

Currency values must be stored and processed with full precision.
To ensure accuracy, the system should:

  • Store money as integer cents (e.g., $10.50 → 1050) instead of floats, or
  • Use a reliable decimal math library (e.g., decimal.js, big.js), and ensure all wallet operations use it.

The database and model should be refactored so no floating-point numbers are used for currency values.

Submission Guidelines

  1. Comment on this issue with your proposed solution approach.
  2. Wait for issue assignment from reviewers.
  3. Create a PR with clear, descriptive commit messages.
  4. Reference this issue in your PR description.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Easyeasy issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions