Skip to content

Fundamental error or misunderstanding of the multiplication/division functions #485

@mittermayr

Description

@mittermayr

My entire reason for switching to currency.js just seems to have gone up in smoke, am I fundamentally wrong or is this actually meant to be:

currency(60.0).divide(1.1).multiply(1.1).format() should be: 60.00

but actually will print: 60.01

I understand why it prints 60.01 (54.545454* gets rounded to 54.55), but I thought the entire reason for using currency.js (and its multiply/divide functions) was to not have this happen?

This of course works: currency(60.0).divide(10).multiply(10).format() prints: 60.00

I read in another issue/comment that this may be a precision issue. But whatever precision I pick, it causes various weird results:

currency(60.0, { precision: 36 }).divide(1.1).multiply(1.1).format() = 59.999999999999992894572642398998141289

Thank you, I'm sure I am misunderstanding something here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions