[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [imp-dev] BigInteger and BigDecimal for pdb.values
|
Can't we use a graceful degradation/promotion mechanism for integral
values?
I.e., detect overflow and produce a value using a larger underlying
representation
as needed. I've never tried to do this in Java, but in C/C++ it's
certainly possible
without gross performance loss (one just does some bit twiddling in
the MSB's
to detect the overflow).
Obviously this won't handle loss of precision in fixed-point decimals,
but
presumably the application developer should know how many decimal
places of precision the application requires.
On Jan 11, 2009, at 10:32 AM, Jurgen Vinju wrote:
Hi!
We're using PDB.values a lot, and I've been able to spend time to
'get it right'. However, there
seems to be one big But.
The PDB integers and doubles are now limited to java Integer and
Double, which is not right for the kind
of functionality that PDB offers. The users of the PDB API should
not have to worry about overflow and
precision. It's the kind of API that offers abstraction from such
details. Also, for the Rascal language which
is built on top of PDB we want to provide a similar abstraction.
So, I propose to change the semantics of pdb integers and doubles to
BigInteger and BigDecimal. Also,
it may be prudent to change the name 'double' to 'decimal' in this
respect.
We will pay in terms of efficiency initially, since I intend to
simple implement these BigIntegers and BigDecimals
using the Java standard library. However, future optimized
implementations of the IValue interfaces can try to
fit numbers in normal ints (like other open-source Big Integer
implementations sometimes do).
--
Cheers,
- Bob
-------------------------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center
IMP Project Lead (http://www.eclipse.org/imp)
X10: Productivity for High-Performance Parallel Programming (http://x10.sf.net
)