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

sqrt(): return positive and negative values #39

Open
helluvamatt opened this issue Jan 24, 2019 · 1 comment
Open

sqrt(): return positive and negative values #39

helluvamatt opened this issue Jan 24, 2019 · 1 comment

Comments

@helluvamatt
Copy link

helluvamatt commented Jan 24, 2019

According to Wikipedia:

In mathematics, a square root of a number a is a number y such that y^2 = a; in other words, a number y whose square (the result of multiplying the number by itself, or y ⋅ y) is a. For example, 4 and −4 are square roots of 16 because 42 = (−4)2 = 16.

To facilitate this, an Operation would be need to handle processing and returning two doubles. Each operation would have to decide if it will operate on the double and possibly filter out double.NaN.

I see this as a major overhaul and a major breaking change, and would require a bump in the major version if following semver.

Once that overhaul is complete, it would be trivial to return new Tuple<double, double>(Math.Sqrt(x), -Math.Sqrt(x)) for the Sqrt function operation. Alternatively, a new internal model could be passed around that includes the double result as well as a flag that indicates the next operation should be performed on both the result and the negation of the result. Edit: This would not work as the next operation may alter the negation result differently and that information would need to be communicated to further operations and eventually the caller.

Thoughts?

@pieterderycke
Copy link
Owner

I am not really convinced of the added value of returning back a tuple. It will complixify the use of Jace without bringing sufficient added value.

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

2 participants