Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 155138 - Complete support of Decimal data type in BIRT
Summary: Complete support of Decimal data type in BIRT
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.1.0   Edit
Hardware: PC Windows 2000
: P2 enhancement (vote)
Target Milestone: 2.3.0 RC0   Edit
Assignee: Jianchao Li CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-24 19:13 EDT by Gary Xue CLA
Modified: 2008-04-24 22:47 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Xue CLA 2006-08-24 19:13:08 EDT
Data type Decimal (which maps to java.math.BigDecimal) support in BIRT engine/data engine is incomplete. Currently decimal values are converted to Double before any calculation and formatting. This behavior is incorrect since it loses the arbitury-precision aspect of the Decimal data type (which is really what Decimal type is designed for).

The proper handling of Decimal type will require that expressions involving Decimal values be calculated outside of the Rhino engine (since Rhino does not handle Decimal types).
Comment 1 Gary Xue CLA 2007-05-30 19:23:51 EDT
The changes to support this were too extensive to fit in 2.2. We will do this in 2.2.1.
Comment 2 Ken Geis CLA 2007-07-27 20:12:10 EDT
Bug 198172 may relate to this.
Comment 3 Gary Xue CLA 2007-08-27 16:58:34 EDT
This does not fit in the 2.2.1 release since it requires that we devise a type of non-Javascript expression in order to move calculation out of Rhino engine. Tentatively moving to 2.3. 
Comment 4 Ken Geis CLA 2007-08-27 18:03:59 EDT
Maybe it would be best to wait for ECMAScript4/JavaScript2, which should include a decimal type.  Then again, the timeline for BIRT is more well defined that the timeline for JavaScript2.
Comment 5 Lin Zhu CLA 2008-04-07 03:07:01 EDT
Set the priority to p5.
Comment 6 Gary Xue CLA 2008-04-07 20:56:34 EDT
Due to the lack of native support for BigDecimal type in Javascript, we are limited in what we can do to offer decimal calculation in BIRT reports. BIRT's Decimal values will be represented as java.math.BigDecimal objects. We plan to add the following Javascript methods to perform BigDecimal calculation. The report designer is required to use these functions to perform calculations involving BIRT's Decimal data types. 

NOTES: 
(N1): The CALCULATION (Non-BigDecimal) column specifies the equivalent Javascript calcualtion to perform, if none of the method operands is of type BigDecimal. 
(N2): The CALCULATION (BigDecimal) column specified the BigDecimal class methods to call to perform the calculation, if all operands are of type BigDecimal.
(N3): If at least one of the operands are of type BigDecimal, the remaining non-BigDecimal operands will be converted to BigDecimal using either BigDecimal.valueOf(), or BigDecimal.BigDecimal(String),  depending on its data type. The claculation will then be done using the method in the CALCULATION (BigDecimal) column.


METHOD                   CALCULATION         CALCULATION 
                        (Non-BigDecimal)     (BigDecimal)
---------------------------------------------------------------
BirtMath.add(x, y)       x + y              x.add(y)
BirtMath.subtract(x,y)   x - y              x.subtract(y)
BirtMath.multiple(x, y)  x * y              x.multiple(y)
BirtMath.divide(x, y)    x / y              x.divide(y, BigDecimal.ROUND_HALF_EVEN)


ADDITIONAL METHODS AND NOTES
(1) BirtMath.safeDivide (x, y, ifZero): Returns BirtMath.divide(x,y) if such division does not result in an ArithmeticException, otherwise return ifZero.
(2) All existing methods in BirtComp name space will need to support BigDecimal data type as operand, converting any non-BigDecimal numeric operands to BigDecimal if necessary as per rule (N3) above
(3) All aggregate functions will need to support BigDecimal. Any non-BigDecimal numeric operands is converted if necessary to BigDecimal as per rule (N3). If the aggregation is over BigDecimal data type, the return value of aggregates should be BigDecimal (instead of double). 
(4) All filter operators need to support BigDecimal operands. Any non-BigDecimal numeric operands is converted if necessary to BigDecimal as per rule (N3).

Comment 7 Gary Xue CLA 2008-04-18 19:01:16 EDT
--- ADDITIONAL NOTE ---
(5) The BIRT Javascript functions under Finance package also needs to support BigDecimal operands.

As an implementation note, it's important that BigDecimal data type be used for calculation only if one or more of the operands are of BigDecimal type. To avoid performance degradations, calculations not involving BigDecimal data type should continue to be done using double/float/integer types as they are today.
Comment 8 Wei Yan CLA 2008-04-20 22:45:33 EDT
ENGINE needs supprt BigDecimal for Financial functions.
Comment 9 Jianchao Li CLA 2008-04-24 22:47:51 EDT
Complete support of Decimal data type in BIRT is accomplished and new test cases are added.