Opened 8 years ago
Closed 8 years ago
#1460 closed defect (fixed)
cast loses precision in petascope
Reported by: | Vlad Merticariu | Owned by: | Bang Pham Huu |
---|---|---|---|
Priority: | major | Milestone: | 9.3 |
Component: | petascope | Version: | development |
Keywords: | Cc: | ||
Complexity: | Medium |
Description
in CrsComputer, in the method getNumericPixelIndicesForIrregularAxes, line 235 + 236, BigDecimal objects are created from Double numbers. This happens with loss of precision.
To avoid, create the BigDecimals from the string representation of the number:
new BigDecimal(numericSubset.getLowerLimit()) → new BigDecimal(numericSubset.getLowerLimit().toString())
Change History (7)
comment:1 by , 8 years ago
follow-up: 3 comment:2 by , 8 years ago
You should find out which are the real coefficients and which is the correct sql query.
comment:3 by , 8 years ago
Replying to vmerticariu:
You should find out which are the real coefficients and which is the correct sql query.
the second query as the coeffcient is 0.
comment:5 by , 8 years ago
Replying to vmerticariu:
Why does the first one produce a different value?
What I can see here is because BigDecimal treat different between Double and String, but need time to understand correctly.
comment:6 by , 8 years ago
the problem is, for example BigDecimal a = new BigDecimal(double) as the result, a will have random fraction numbers after the real value of double.
e.g: double = 0.2356
then a will have value: 0.235653485834584395929090423904902349023904290349023904
so must use BigDecimal(double.toString()) wherever it is used.
comment:7 by , 8 years ago
Milestone: | → 9.3 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
The patch was applied, close ticket.
this ticket when fixed as Vlad suggested will have problem when ingesting coverage irr_cube_2 first slice, the SQL query is
and it will return 0 coeffecient and exception
before the patch, the SQL query is
so it can return 1 coeffcient (0)
So I think it should be fixed from all other places which used Double as well.