-
Notifications
You must be signed in to change notification settings - Fork 11
Description
I'm creating this issue to suggest a breaking change, that would be to make all static methods also accepts a tuple [number, number] as argument (not only a Double) and always return a tuple [number, number] instead of mutating the given double instance and returning it. This would prevent unwanted mutations and still allow faster calculations than when using the instance methods which for most of them require the construct of a new instance. For example instead of :
static add22(X: Double, Y: Double): Double We would have :
static add22(X: Double, Y: Double): [number, number]
static add22(X: [number, number], Y: [number, number]): [number, number]And in the implementation :
const [xhi, xlo] = X;
const [yhi, ylo] = Y;
// ...
return [zhi, zlo];For the same reason (performance) and for consistency, the functions twoSum, twoProd, and oneSqr would also return a tuple instead of a double-like object.
If the idea sounds good, or if you want to see something concrete before making the decision, I can make a PR.