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

ASF GitHub Bot commented on TINKERPOP3-750:
-------------------------------------------

GitHub user mhfrantz opened a pull request:

    https://github.com/apache/incubator-tinkerpop/pull/96

    TINKERPOP3-750: Compare Number as BigDecimal

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/RedSeal-co/incubator-tinkerpop 
TINKERPOP3-750-Compare-Number-as-BigDecimal

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-tinkerpop/pull/96.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #96
    
----
commit e1917173d8a44b97799ecffb405948e0549af6d6
Author: mhfrantz <[email protected]>
Date:   2015-08-31T18:42:35Z

    TINKERPOP3-750: Test large number comparison
    
    Repro for comparisons that are sensitive to loss of precision when 
converting Number to double.

commit 378dd6cb920c9ac82ce53cc599882bf0704a3ab6
Author: mhfrantz <[email protected]>
Date:   2015-08-31T20:25:40Z

    TINKERPOP3-750: Fix bug in Compare for BigInteger/BigDecimal by converting 
Number to BigDecimal

----


> Compare should not have special case for Number
> -----------------------------------------------
>
>                 Key: TINKERPOP3-750
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-750
>             Project: TinkerPop 3
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.0.0-incubating
>            Reporter: Matt Frantz
>            Assignee: Matt Frantz
>             Fix For: 3.0.1-incubating, 3.1.0-incubating
>
>
> The current implementation of {{Compare}} has a special case for {{Number}} 
> which uses {{doubleValue}} for all comparisons.  However, this fails for some 
> implementations of {{Number}}, e.g. {{BigInteger}}.  Also, most 
> implementations of {{Number}} implement {{Comparable}} for appropriately 
> typed arguments.  It should be more robust and less surprising to simply use 
> {{Object.equals}} and {{Comparable.compareTo}}.  This would also be more 
> performant as it removes the {{instanceof}} checks.
> If we want the option of treating all numbers as doubles, perhaps something 
> called {{CompareDouble}} would be more appropriate.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to