Skip to content

Commit

Permalink
HPCC4J-562 Odd unsigned decimals incorrect scale
Browse files Browse the repository at this point in the history
- Corrected BinaryRecordReader unsigned decimal parse code
- Updated ECL test datasets to include odd precision decimal values

Signed-off-by: James McMullan [email protected]
  • Loading branch information
jpmcmu committed Dec 13, 2023
1 parent deee138 commit 2444f57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,15 @@ private BigDecimal getUnsignedDecimal(int numDigits, int precision, int dataLen)
BigDecimal ret = new BigDecimal(0);

int idx = 0;
int curDigit = numDigits - 1;
int curDigit = numDigits;

// If the # of digits is odd the top most nibble is unused and we don't want to include it
// in the scale calculations below. Due to how the scale calculation works below this means
// we decrement the starting value of curDigit in the case of even length decimals
if ((numDigits % 2) == 0)
{
curDigit--;
}

while (idx < dataLen)
{
Expand Down
7 changes: 6 additions & 1 deletion dfsclient/src/test/resources/generate-datasets.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ childRec := {STRING8 childField1, INTEGER8 childField2, REAL8 childField3};
rec := {INTEGER8 int8, UNSIGNED8 uint8, INTEGER4 int4, UNSIGNED4 uint4,
INTEGER2 int2, UNSIGNED2 uint2,
REAL8 r8, REAL4 r4,
DECIMAL16_8 dec16, UDECIMAL16_8 udec16,
DECIMAL16_8 dec16,
DECIMAL15_8 dec15,
UDECIMAL16_8 udec16,
UDECIMAL15_8 udec15,
QSTRING qStr,
STRING8 fixStr8,
STRING str,
Expand All @@ -33,7 +36,9 @@ ds := DATASET(totalrecs1, transform(rec,
self.r8 := (REAL)(random() % unique_values);
self.r4 := (REAL)(random() % unique_values);
self.dec16 := (REAL)(random() % unique_values);
self.dec15 := (REAL)(random() % unique_values);
self.udec16 := (REAL)(random() % unique_values);
self.udec15 := (REAL)(random() % unique_values);
self.qStr := (STRING)(random() % unique_values);
self.fixStr8 := (STRING)(random() % unique_values);
self.str := (STRING)(random() % unique_values);
Expand Down

0 comments on commit 2444f57

Please sign in to comment.