You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/04/16 21:51:00 UTC

[jira] [Work logged] (NUMBERS-147) Fraction/BigFraction from(double, int) should support Integer.MIN_VALUE as max denominator

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

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

                Author: ASF GitHub Bot
            Created on: 16/Apr/20 21:50
            Start Date: 16/Apr/20 21:50
    Worklog Time Spent: 10m 
      Work Description: aherbert commented on pull request #78: NUMBERS-147: Fix Fraction conversion from double to support 2^31
URL: https://github.com/apache/commons-numbers/pull/78
 
 
   The value 2^31 can be in the numerator or denominator. Previously the
   conversion from double supported up to Integer.MAX_VALUE which is
   2^31-1.
   
   Adds common test cases for conversion from double with a max
   denominator.
   
   Changed the conversion from a double to use the absolute value and
   restore the sign at the end. The conversion is thus identical for
   positive or negative values.
   
   A maximum denominator of zero is not allowed and results in an IllegalArgumentException.
   
 
----------------------------------------------------------------
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:
users@infra.apache.org


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

            Worklog Id:     (was: 423779)
    Remaining Estimate: 0h
            Time Spent: 10m

> Fraction/BigFraction from(double, int) should support Integer.MIN_VALUE as max denominator
> ------------------------------------------------------------------------------------------
>
>                 Key: NUMBERS-147
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-147
>             Project: Commons Numbers
>          Issue Type: Bug
>          Components: fraction
>    Affects Versions: 1.0-beta1
>            Reporter: Alex Herbert
>            Assignee: Alex Herbert
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Fraction allows the use of Integer.MIN_VALUE for the denominator. The conversion from a double using a maximum denominator only supports values up to Integer.MAX_VALUE. This is a legacy from when Fraction was limited to Integer.MAX_VALUE in the denominator.
> Currently this test fails:
> {code:java}
>     @Test
>     public void testFromDoubleUsingMaxDenominator() {
>         Fraction f1 = Fraction.of(-1, Integer.MIN_VALUE);
>         Fraction f2 = Fraction.from(f1.doubleValue(), Integer.MIN_VALUE);
>         Assertions.assertEquals(f1, f2);
>     }
> {code}
> It should be possible to round-trip the most extreme small value that can be stored in a fraction to a double and then back again.
> The method requires updating to set the overflow limit (which is a long) as 2^31 and not 2^31-1.
> The same method is used in BigFraction.from which should also be updated.



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