Bug 225695 - BIRT's numeric format can produce "-0"
Summary: BIRT's numeric format can produce "-0"
Status: VERIFIED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.2.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.5.0 M7   Edit
Assignee: Haojun Chu CLA
QA Contact: Maggie Shen CLA
URL:
Whiteboard: Autoed
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2008-04-04 01:24 EDT by Paul Rogers CLA
Modified: 2009-06-17 01:58 EDT (History)
4 users (show)

See Also:


Attachments
Product Sales by Country.rptdesign (83.03 KB, text/plain)
2008-04-04 01:24 EDT, Paul Rogers CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Rogers CLA 2008-04-04 01:24:57 EDT
Created attachment 94811 [details]
Product Sales by Country.rptdesign

Open the attached report that uses the Classic Models sample database. Preview it.

Notice on the line for Australia, NSW, the change is "-0".

This is probably due to rounding errors. The value is probably something like -0.1 which, when rounded to no digits past the decimal displays as 0, but the negative calculation is done off of the original value.

The only problem is, aside from cryptic computer math cases, -0 is the same as 0 and is displayed as 0.

The workaround, I guess, is for me to do my own rounding in the expression for the field, but this means that the field no longer holds the actual number an can affect downstream uses of that field. Plus, it is just more work for the developer.

Expected that BIRT would do the right thing for me. If I specify rounding (by saying 0 digits past the decimal point), BIRT will round the number first, THEN apply the negative sign if needed. This is the technique used in most other software, such as Excel.
Comment 1 Rick Lu CLA 2008-04-10 05:31:32 EDT
By viewing the attach design, it is -0.24 that has been round -0. It is an issue in number format.

Please know to use the attached design in 2.3. Need to manually change dataSetRow["ORDERDATE"] to new Date(dataSetRow["ORDERDATE"].getTime()). Detail reasons seen in https://bugs.eclipse.org/bugs/show_bug.cgi?id=226409.
Comment 2 Haojun Chu CLA 2008-04-15 01:08:12 EDT
I used latest 2.3 and replaced all the string as Rick mentioned, but I don't get something like -0.

In fact, the change value I get is either 0 or NaN. On the line Australia-NSW, the change value is NaN.

Paul, could you try the latest build?
Comment 3 Wei Yan CLA 2008-04-15 02:50:07 EDT
BIRT uses the java's DecimalFormat to format the number, the #,##0 do generate -0 in this case.

I think -0 is acceptable is this case, see http://en.wikipedia.org/wiki/%E2%88%920_(number)
and 
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html
Comment 4 Paul Rogers CLA 2008-04-23 19:43:24 EDT
It is unfortunate that the underlying Java code has a bug. Still, the issue here is that business users of reports don't expect to see a -0 or (0) in the report output. As a result, someone will have to implement a workaround. As it is now, it is each report developer who must 1) discover the problem, and 2) devise a workaround.

This is one of those cases where there is really only one right way to solve the problem. Rather than forcing each report developer to figure out that solution, it would be much better to devise the workaround only once and implement it in the core BIRT code.

Just to be clear, the request here was to make the output be correct for what business users expect. If third-party code that BIRT chooses to use does the formatting wrong, then the request is to work around or fix the problem so that report users get the result they expect.
Comment 5 Paul Rogers CLA 2008-05-07 19:47:41 EDT
It is very easy to reproduce this bug in BIRT 2.2 with a very simple design. You don't need the original example report, if that report is no longer compatible with later BIRT versions.

1. Create a new report.

2. Drag a Data Item from the palette. Set its value to -0.001

3. Using the property editor, go to the Format Number tab. Choose Currency.

4. Preview. The data item value is shown as -0.00
Comment 6 Wei Yan CLA 2008-05-12 04:15:12 EDT
Both the NumberFormatter in Java and ICU are all create the result as -0. To resolve this issue, BIRT need re-write the number format package completely.

BIRT can't fix this issue by checking the result to see if it is -0 as the user can generate such result explicitly as: #.##;-#.##.

defer to future to see if ICU or JAVA could fix this issue.
Comment 7 Haojun Chu CLA 2009-04-28 03:31:08 EDT
Fixed. Checked in on Apr 28.
Comment 8 Maggie Shen CLA 2009-04-30 01:32:39 EDT
verified on build 2.5.0 v20090430-0630.-0.001 will be displayed as 0.00 if only two decimals are allowed.