[ 
https://issues.apache.org/jira/browse/NUMBERS-132?focusedWorklogId=291441&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-291441
 ]

ASF GitHub Bot logged work on NUMBERS-132:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Aug/19 17:30
            Start Date: 08/Aug/19 17:30
    Worklog Time Spent: 10m 
      Work Description: asfgit commented on pull request #67: NUMBERS-132: 
Perform gcd algorithm on negative numbers in ArithmeticUtils.gcd(int, int)
URL: https://github.com/apache/commons-numbers/pull/67
 
 
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 291441)
    Time Spent: 0.5h  (was: 20m)

> ArithmeticUtils.gcd(int, int) can be simplified by performing the gcd 
> algorithm on negative numbers
> ---------------------------------------------------------------------------------------------------
>
>                 Key: NUMBERS-132
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-132
>             Project: Commons Numbers
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.0
>            Reporter: Heinrich Bohne
>            Priority: Minor
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The method {{ArithmeticUtils.gcd(int, int)}} currently handles the special 
> case of the non-negatable {{Integer.MIN_VALUE}} by converting the arguments 
> to {{long}}s if one of them is {{Integer.MIN_VALUE}} and performing two 
> iterations of the regular euclidean algorithm before handing the resulting 
> values over to a helper method that performs the binary gcd algorithm.
> However, the tactic used by {{gcd(long, long)}} is much more elegant: It just 
> converts positive arguments to their negative counterparts, thereby avoiding 
> the risk of overflow completely without having to make exceptions for special 
> cases and resorting to other data types.
> The method {{gcd(int, int)}} would likely be much more compact if it also 
> were to apply this technique.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to