You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "William Rossi (JIRA)" <ji...@apache.org> on 2010/08/29 14:05:53 UTC

[jira] Created: (MATH-412) Add high precision decimal floating point library (dfp)

Add high precision decimal floating point library (dfp)
-------------------------------------------------------

                 Key: MATH-412
                 URL: https://issues.apache.org/jira/browse/MATH-412
             Project: Commons Math
          Issue Type: New Feature
         Environment: JDK1.4 - JDK1.6
            Reporter: William Rossi


I am offering the dfp library available at http://sourceforge.net/projects/dfp/ to the project.  I've dual licensed the project under ASF and LGPL.   I will submit a software grant shortly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-412) Add high precision decimal floating point library (dfp)

Posted by "William Rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905244#action_12905244 ] 

William Rossi commented on MATH-412:
------------------------------------


I agree that the way I choose the precision at compile time is 
sub-optimal, but I have a few questions about this approach.  The 
constants such as one, zero, two, etc in Dfp are there because they come 
up all the time and I didn't want to waste a lot of memory creating them 
all the time.  So any factory should give out the same references for 
these.

The other concern is that it shouldn't be allowed to do 
operations between Dfp instances of different precisions unless we 
can very clearly define what that means.   I think that such implicit
conversions could be a source of problems, and confusion.  This was the 
main motivation of having them as separate classes.   I wanted them to 
behave as much like the primitive floating point types as possible, hence 
the support for IEEE constructs such as NaN, etc.

Ideally I would have used something like a template in C++, but that wasn't
an option at all in JDK 1.4, and I'm still not sure if generics in 1.5+ are
up to the task.   It might be possible if the Dfp took as a type argument 
a traits class which specified the precision and held references to 
constants?

Another possibility is to make Dfp abstract and have thin subclasses 
specify the precision, trap behaviour, constants, etc.   I started to do 
some work along those lines which is why the newInstance() method exists. 
This would allow us to have proper copy constructors to do conversions 
between precisions explicitly.




> Add high precision decimal floating point library (dfp)
> -------------------------------------------------------
>
>                 Key: MATH-412
>                 URL: https://issues.apache.org/jira/browse/MATH-412
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 2.1
>         Environment: JDK1.4 - JDK1.6
>            Reporter: William Rossi
>            Assignee: Luc Maisonobe
>             Fix For: 2.2
>
>
> I am offering the dfp library available at http://sourceforge.net/projects/dfp/ to the project.  I've dual licensed the project under ASF and LGPL.   I will submit a software grant shortly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (MATH-412) Add high precision decimal floating point library (dfp)

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luc Maisonobe updated MATH-412:
-------------------------------

        Fix Version/s: 2.2
    Affects Version/s: 2.1

> Add high precision decimal floating point library (dfp)
> -------------------------------------------------------
>
>                 Key: MATH-412
>                 URL: https://issues.apache.org/jira/browse/MATH-412
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 2.1
>         Environment: JDK1.4 - JDK1.6
>            Reporter: William Rossi
>            Assignee: Luc Maisonobe
>             Fix For: 2.2
>
>
> I am offering the dfp library available at http://sourceforge.net/projects/dfp/ to the project.  I've dual licensed the project under ASF and LGPL.   I will submit a software grant shortly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-412) Add high precision decimal floating point library (dfp)

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905227#action_12905227 ] 

Luc Maisonobe commented on MATH-412:
------------------------------------

Rather than an abstract Dfp class, a better approach seem to have a single concrete class Dfp (which can be subclassed as with DfpDec and Decimal10 in the test suite) and a DfpFactory.
The factory is created by specifying the numbers of digits. Also instead of having the static fields zero, one, two inf Dfp and SQR2, SQR3, PI ... in DfpMath, all these constants can be accessed as factory.getZero(), factory.getPi() ...
In fact, the factory plays roughly the same role as the ant filtering process and the constants utility. It simply is run at factory creation time.

> Add high precision decimal floating point library (dfp)
> -------------------------------------------------------
>
>                 Key: MATH-412
>                 URL: https://issues.apache.org/jira/browse/MATH-412
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 2.1
>         Environment: JDK1.4 - JDK1.6
>            Reporter: William Rossi
>            Assignee: Luc Maisonobe
>             Fix For: 2.2
>
>
> I am offering the dfp library available at http://sourceforge.net/projects/dfp/ to the project.  I've dual licensed the project under ASF and LGPL.   I will submit a software grant shortly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (MATH-412) Add high precision decimal floating point library (dfp)

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luc Maisonobe resolved MATH-412.
--------------------------------

    Resolution: Fixed

Fixed in subversion tree as of r992696 for branch 2.X and as of r992697 for trunk.

The Dfp class represent the high precision numbers, it implements our existing Field interface and hence each instance is associated with a DfpField that provides the constants at the required precision as well as factory methods. This allowed to remove the compile-time constraint in the library. Users can even use at the same time a field for 20 decimals digits precision and another field for 100 digits precision. Dfp instances with different precision CANNOT be mixed in the same computation (doing so creates a NaN).

A few utility methods have been added, like constructors from integral types, isInfinite and isNaN methods, equal has been renamed to equals and its signature changed to match the general Object method (a hashcode method has been added too).

Thank you very much for this contribution.

> Add high precision decimal floating point library (dfp)
> -------------------------------------------------------
>
>                 Key: MATH-412
>                 URL: https://issues.apache.org/jira/browse/MATH-412
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 2.1
>         Environment: JDK1.4 - JDK1.6
>            Reporter: William Rossi
>            Assignee: Luc Maisonobe
>             Fix For: 2.2
>
>
> I am offering the dfp library available at http://sourceforge.net/projects/dfp/ to the project.  I've dual licensed the project under ASF and LGPL.   I will submit a software grant shortly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MATH-412) Add high precision decimal floating point library (dfp)

Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905169#action_12905169 ] 

Luc Maisonobe commented on MATH-412:
------------------------------------

I started integrating your dfp library.
I wonder if it would be useful to remove the compile-time constraint on number of digits. A quick glance showed me it would basically mean changing the dfp class (which I renamed Dfp for consistency with our checkstyle settings) into an abstract class without the public final DIGITS field but with a public abstract method getDigits() or getRadixDigits to avoid confusion with DfpDec.getDecimalDigits().

This way, user would remain free to choose the precision they need at run time.

In the existing code, the various use of DIGITS could be replaced either by calls to getRadixDigits() or by mant.length.
Building a new instance from scratch would require an additional argument to set the number of digits, and building instances related to other instances (for example when adding two Dfp instances) would rely on the initial number settings.
For simplicity, operations between instances with different digits settings would be forbidden (using an unchecked exception ...)

Do yo think this could work ?


> Add high precision decimal floating point library (dfp)
> -------------------------------------------------------
>
>                 Key: MATH-412
>                 URL: https://issues.apache.org/jira/browse/MATH-412
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 2.1
>         Environment: JDK1.4 - JDK1.6
>            Reporter: William Rossi
>            Assignee: Luc Maisonobe
>             Fix For: 2.2
>
>
> I am offering the dfp library available at http://sourceforge.net/projects/dfp/ to the project.  I've dual licensed the project under ASF and LGPL.   I will submit a software grant shortly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.