You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles (JIRA)" <ji...@apache.org> on 2019/01/23 15:49:00 UTC

[jira] [Commented] (NUMBERS-90) DoublePrecisionContext

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

Gilles commented on NUMBERS-90:
-------------------------------

Currently, I fail to see how, for general use, the "contexts" are an improvement over direct calls to the functions in class {{Precision}}.
 Could you perhaps first build an actual use-case? I.e. I'd propose to define them in an {{internal}} package of "Commons Geometry" (where you said you have one); then we can better see the usage pattern and decide what can be extracted into "Commons Numbers".

Another point: Is it intended that the "eps" is absolute in {{EpsilonDoublePrecisionContext}}?
 I'd have thought (?) that the purpose was to easily [compare numbers of similar sizes|https://gitbox.apache.org/repos/asf?p=commons-numbers.git;a=blob;f=commons-numbers-core/src/main/java/org/apache/commons/numbers/core/Precision.java;h=3503cf29c75dca5460e6d4a7c215941245d5bb7e;hb=HEAD#l326].

> DoublePrecisionContext
> ----------------------
>
>                 Key: NUMBERS-90
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-90
>             Project: Commons Numbers
>          Issue Type: New Feature
>            Reporter: Matt Juntunen
>            Priority: Blocker
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> We should add a new class to commons-numbers-core that encapsulates configurable strategies for comparing doubles. This is required for GEOMETRY-11. Here is what I'm picturing:
> {code:java}
> // abstract class for the general concept of comparisons
> public abstract class DoublePrecisionContext implements Comparator<Double> {
>     public abstract boolean equals(double a, double b);
>     public int compare(double a, double b) { /* ... */ }
>     public int compare(Double a, Double b) { /* ... */ }
> }
> // ...
> // concrete class implementing a specific strategy
> public class EpsilonUlpDoublePrecisionContext extends DoublePrecisionContext {
>     public EpsilonUlpDoublePrecisionContext(double eps, double maxUlps) { /* ... */ }
>     @Override
>     public boolean equals(double a, double b) { /* ... */ }
> } {code}
> Pull request: https://github.com/apache/commons-numbers/pull/28



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)