commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William Rossi (JIRA)" <>
Subject [jira] Commented: (MATH-412) Add high precision decimal floating point library (dfp)
Date Wed, 01 Sep 2010 22:01:02 GMT


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 

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 

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:
>             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 to the
project.  I've dual licensed the project under ASF and LGPL.   I will submit a software grant

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

View raw message