[
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.