When to return a "simpler" type than a function was invoked with? #3398
gwhitney
started this conversation in
Design decisions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The discussion in #3374 outlining how mathjs will uniformize when mathjs returns different types with config.predictable = false and how it will behave in out-of-domain cases with config.predictable = true has explicitly opened the door to functions returning a "simpler" type when it happens to be exact, e.g.
floor
of a BigNumber could be a bigint, if that's useful. It turns out that a couple of functions that typically return a complex number already return a plain number when the imaginary part of the result happens to be zero, and certainly those examples should be regularized and that principle, assuming it's deemed valuable, should be extended to other functions. This discussion is dedicated to determining other cases, if any, when such "type simplification" could and should occur.Beta Was this translation helpful? Give feedback.
All reactions