[
https://issues.apache.org/jira/browse/MATH-1047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13805359#comment-13805359
]
Gilles commented on MATH-1047:
------------------------------
For {{pow(int,int)}}, that's smarter, indeed.
A small caveat is that a failing "mulAndCheck" will create a less meaningful
message.
For the methods involving "long", {{mulAndCheck(long, long)}} seems to contain
more branches that cannot be optimized away. And more operations.
Since the code is far from obvious (due to bit-fiddling), it seems that the
intention was to make it as efficient as possible. Calling "mulAndCheck" might
defeat the purpose in some contexts (where the developer would then prefer to
write the operation using an explicit loop).
> No check for overflow in "ArithmeticUtils.pow"
> ----------------------------------------------
>
> Key: MATH-1047
> URL: https://issues.apache.org/jira/browse/MATH-1047
> Project: Commons Math
> Issue Type: Improvement
> Affects Versions: 3.2
> Reporter: Gilles
> Labels: safety
> Fix For: 3.3
>
> Attachments: MATH-1047.patch
>
>
> The "pow" methods in "o.a.c.m.util.ArithmeticUtils" do not check for overflow.
> They will happily return nonsensical results.
--
This message was sent by Atlassian JIRA
(v6.1#6144)