Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isX() quality of life functions #178

Open
JamesCarlyleClarke opened this issue Feb 28, 2025 · 0 comments
Open

isX() quality of life functions #178

JamesCarlyleClarke opened this issue Feb 28, 2025 · 0 comments

Comments

@JamesCarlyleClarke
Copy link

JamesCarlyleClarke commented Feb 28, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant