Skip to content

isX() quality of life functions #178

@JamesCarlyleClarke

Description

@JamesCarlyleClarke

Hi there,
Maybe I'm missing something, but could we get some quality of life functions?
For example, you already have isFinite() and isNaN(); to avoid having to create a Decimal for comparison sake, or relying on internal structures within the library that might change, could we have the equivalents of:

From break_infinity.js

isNegativeInfinity()   - https://patashu.github.io/break_infinity.js/classes/default.html#isNegativeInfinity
isPositiveInfinity()   - https://patashu.github.io/break_infinity.js/classes/default.html#isPositiveInfinity

From decimal.js

isNegative() or isNeg()   - https://mikemcl.github.io/decimal.js/#isNeg
isPositive() or isPos()   - https://mikemcl.github.io/decimal.js/#isPos
isZero()   - https://mikemcl.github.io/decimal.js/#isZero

You could also have isInteger(), isMax(), isMin(), etc.

Hope that helps, thanks for a great library.

Additional:
I know/believe we could do something like this isNegative():

function isNegative(decimal) {
    return decimal.sign === -1;
}

or the shorter

if (decimal.sign === -1) {
}

I just feel that a set of standard helper functions would be great, and would help separate our code from internal structures and representations.

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