Community
Participate
Working Groups
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).
The changes to support this were too extensive to fit in 2.2. We will do this in 2.2.1.
Bug 198172 may relate to this.
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.
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.
Set the priority to p5.
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).
--- 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.
ENGINE needs supprt BigDecimal for Financial functions.
Complete support of Decimal data type in BIRT is accomplished and new test cases are added.