commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles Sadowski (Jira)" <j...@apache.org>
Subject [jira] [Comment Edited] (NUMBERS-99) Fraction.add(int) and Fraction.subtract(int) ignore risk of integer overflow
Date Mon, 07 Oct 2019 02:04:00 GMT

    [ https://issues.apache.org/jira/browse/NUMBERS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16945537#comment-16945537
] 

Gilles Sadowski edited comment on NUMBERS-99 at 10/7/19 2:03 AM:
-----------------------------------------------------------------

The attached patch removes the requirement that only the numerator can be negative.  Please
review.
Note: Some of the "common" unit tests had to be commented out (because of their assumptions
about "implementation details").


was (Author: erans):
The attached patch removes the requirement that only the numerator can be negative.  Please
review.

> Fraction.add(int) and Fraction.subtract(int) ignore risk of integer overflow
> ----------------------------------------------------------------------------
>
>                 Key: NUMBERS-99
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-99
>             Project: Commons Numbers
>          Issue Type: Bug
>          Components: fraction
>            Reporter: Heinrich Bohne
>            Priority: Minor
>         Attachments: NUMBERS-99.patch
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> The methods {{add(int)}} and {{subtract(int)}} in the class {{org.apache.commons.numbers.fraction.Fraction}}
do not take into account the risk of an integer overflow. For example, (2​^31^ - 1)/2 +
1 = (2​^31^ + 1)/2, so the numerator overflows an {{int}}, but when calculated with {{Fraction.add(int)}},
the method still returns normally.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message