Implement max and min functions for Apfloat and Apint
Closed this issue · 3 comments
java.lang.Math implements max and min methods which help API consumers reduce boilerplate and not having to reinvent the wheel. It would certainly be helpful to also offer this option for at least the Apfloat and Apint types; the worst case execution times shouldn't be more than O(n), where n is digit count.
Assumed API call would look as such: ApfloatMath.max(apfloatOne, apfloatTwo);
An arbitrary number of arguments could also be supported, but then the algorithm time becomes O(n^2) in the worst case; this would likely not be of much use to the majority of consumers.
Good idea, these are indeed missing.
For an arbitrary number of arguments, I suppose the complexity would be O(mn) where m is the number of arguments and n is the number of digits in the numbers. Probably, as you suggest, only implementing the two-argument version of the functions is worthwhile.
I think you're more aware of the implementation details than I am, so I trust your judgement. Should I try my hand at this feature? If yes, are there any dev guideline resources I can reference so my code fits in better with the rest?
I have an implementation for this, I will be pushing the commit shortly.