Skip to content

Implement Math.Max and Math.Min functions for BigNumber #167

@OrlandoP97

Description

@OrlandoP97

Hello,

I am currently working on a project where I need to calculate the maximum and minimum values from an array of BigNumber objects. I noticed that there are no functions in the library to handle this for BigNumber objects (or maybe I couldn't found it), similar to Math.max and Math.min for numbers.

The current workaround is to convert the BigNumber objects to numbers and then use Math.max or Math.min. However, this approach has a significant drawback. When two similar but slightly different BigNumber objects are converted to numbers, they could be converted to the same number due to the loss of precision. This results in an inaccurate selection of the minimum and maximum values.

I suggest implementing two new functions, max and min, that can handle arrays of BigNumber objects. These functions would maintain the precision of the BigNumber objects and provide accurate results.

Thank you for considering this suggestion. I believe these functions would be a valuable addition to the BigNumber class and would benefit many developers working with large numbers.

Best regards, Orlando

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