Skip to content

Core Economy representation in double #1

Description

@Jhiynn

I noticed Ecotale represents money using double. That’s risky long-term because double is binary floating-point, so many decimal values (like 0.01 / 0.1) can’t be represented exactly. Over time, rounding errors accumulate and you can get drifting balances (cents “disappearing” or “appearing”), inconsistent calculations, or checks like balance >= price failing unexpectedly. With lots of transactions, taxes, discounts, or interest, this becomes a real integrity problem.

Best practice for currency is usually:
long in minor units (e.g., cents) and only format to decimals for display, or
BigDecimal (and DECIMAL in DB) with a fixed scale and explicit rounding rules
Would you be willing to change this (or add an optional mode with a migration path) to long/BigDecimal?

Thanks

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions