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

If Decimal128 is supported, should those methods and options be added to Number? #62

Open
dead-claudia opened this issue Aug 30, 2021 · 3 comments

Comments

@dead-claudia
Copy link

Given Decimal128 is in terms of IEEE-754 decimal128 and Number is in terms of IEEE-754 binary64, I feel it'd make sense to extend these methods to that for consistency.

This of course is more a suggestion for a follow-on, and also some food for thought (it raises questions on rounding mode handling in general).

@munrocket
Copy link

Thanks for this issue! I am thinking that we need to expose scalar FMA in the web according to IEEE-754 with slow but correctly rounded version if it not supported in processor

let x = Math.fma(a, b, c);

In this way we can implement binary arbitrary floating point in user space libraries insanely fast in most of devices, I have done proposal in tc39 discourse https://es.discourse.group/t/math-float-optimisation/829/14 but not sure that I have good explanation there why we need it.

{ round: "up/down/0/ne” } mode from future Decimal inside Number can be useful, as I know it also can be done with this basic functions (like in Java)

let successor = Math.nextUp(x);
let predecessor = Math.nextDown(x)

@sarahghp
Copy link
Contributor

sarahghp commented Feb 1, 2022

@isiahmeadows I am not certain I understand which methods you are referring to in the original post? Could you elaborate a bit more about the methods and how they make sense with the Decimal proposal?

@dead-claudia
Copy link
Author

@sarahghp I'm referring to these, which lack any corresponding Number equivalent:

  • Decimal128.round(decimal, options)
  • Decimal128.div(a, b, options)
  • Decimal128.pow(decimal, number, options)
  • Decimal128.partition(decimal, pieces, roundingOptions)

Of these, div and pow do have equivalents without options, but not with options. This is why I brought it up.

@munrocket That would be better suited for https://github.com/rwaldron/proposal-math-extensions or https://github.com/phoddie/integer-and-modulus-math-proposal (it's stage 1, just the README needs updated).

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

3 participants