Sitelet https://github.com/autoNumeric/autoNumeric/issues/792
Skip to content

The format function with the percentageUS3dec predefined option doesn't work properly when the input is a number and is sufficiently close to 0 #792

Description

@xuhdev

Current behavior

console.log(AutoNumeric.format(<A floating point number that is very close to 0>, AutoNumeric.getPredefinedOptions().percentageUS3dec))

outputs 10.000%.

Expected behavior

Outputs 0.000%.

Steps to reproduce the problem

  1. Copy and paste the following to package.json:
{
  "type": "module",
  "dependencies": {
    "autonumeric": "^4.10.5"
  }
}
  1. Run npm install.

  2. Copy and paste the following to a.js:

import AutoNumeric from "autonumeric";

console.log(AutoNumeric.format(0.0000000000000000001, AutoNumeric.getPredefinedOptions().percentageUS3dec));
  1. Observe the output (which is 10.000% in my setup).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions