-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
category:expressionsIssues about the expression parser, variable scoping etc.Issues about the expression parser, variable scoping etc.design decisionhelp wanted
Description
Am I missing something, or is it the case that there is no way to get the numerator and denominator of a Fraction in the mathjs expression language? For Complex numbers, we have re(z) and im(z) but I don't think that there's anything analogous for Fractions, and if f is a fraction, then f.n and f.d are disallowed property accesses, just like z.re and z.im are for Complex. But these are important properties of a rational number, that we should definitely provide some way of obtaining.
If I am correct that there is currently no way of obtaining them, we should definitely make them available, possibly by one (or both?) of these routes: (would definitely love a clear opinion on which way to go)
- Add functions
numeratoranddenominator. I think they would only be defined on Fractions (and I guess bigints) though, which is a little weird for mathjs, although they would then also work on any types that have automatic conversion to Fraction (not sure what types those are, if any). - In the safety code gatekeeping property access, open up specific allowances that would make
f.nandf.d(and maybef.s) legal (and then one would probably doz.reandz.imfor Complex while at it).
Metadata
Metadata
Assignees
Labels
category:expressionsIssues about the expression parser, variable scoping etc.Issues about the expression parser, variable scoping etc.design decisionhelp wanted