Skip to content

Utilities.formatToPrecision has wrong output for scientific notation #778

Open
@JeneaVranceanu

Description

@JeneaVranceanu

What happened?

Calling Utilities.formatToPrecision(..., fallbackToScientific: true) outputs a wrong value for some inputs.

Screenshot 2023-02-13 at 11 54 37

What are the steps to reproduce?

let balance = BigInt("100000000000000000000")
let formatted = Utilities.formatToPrecision(balance, units: .ether, decimalSeparator: ",", fallbackToScientific: true)

What is the expected behavior?

Value in formatted from the example above should be 1e20 but it's 0e-18 instead.

What is the error thrown?

What's the stack trace said?

OS version

Library version

3.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions