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

NumericSpec and operations on numeric #4979

Open
mversic opened this issue Aug 19, 2024 · 3 comments
Open

NumericSpec and operations on numeric #4979

mversic opened this issue Aug 19, 2024 · 3 comments
Labels
question Further information is requested

Comments

@mversic
Copy link
Contributor

mversic commented Aug 19, 2024

          I think it's better to remove the validation and mention in the docs that mul and div can cause the numeric spec to change, and that users need to do their own validation as necessary. This impl assumes too much, there are multiple ways to handle it (round to `self`, round to provided `spec`, return none if accuracy goes out of bounds, etc)

What are the intended use cases of these ops?

Originally posted by @nxsaken in #4976 (comment)

@mversic mversic added the question Further information is requested label Aug 19, 2024
@Erigara
Copy link
Contributor

Erigara commented Sep 30, 2024

Initail design for Numeric was to provide minimal amount of operations.
If smt fancy is required user should:

  1. convert it to the appropriate type (from mantissa and scale methods)
  2. do operation on this type
  3. convert back to Numeric

@mversic
Copy link
Contributor Author

mversic commented Oct 2, 2024

Initail design for Numeric was to provide minimal amount of operations.

and what do you think of the approach taken in the linked PR? where explicit spec is required on every operation.

If smt fancy is required user should:
convert it to the appropriate type (from mantissa and scale methods)
do operation on this type
convert back to Numeric

I wasn't aware of this, the problem was that there was no way to convert Numeric into f64

@mversic
Copy link
Contributor Author

mversic commented Oct 2, 2024

except that checked_add and checked_sub are now odd ones out

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

No branches or pull requests

3 participants