Project

General

Profile

Bug #9125

Failure to convert decimal variables that exceed 50 decimals.

Added by Artur Școlnic almost 2 years ago. Updated almost 2 years ago.

Status:
Review
Priority:
Normal
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

History

#1 Updated by Artur Școlnic almost 2 years ago

In 4gl, any trailing zeros for decimal values are trimmed in order to honor the precision of 50.

define variable v_dec as decimal.
v_dec = 4000000000000000000000000000000000000000000000.0000000000.

In 4gl this is a valid definition of the decimal, in FWD the conversion fails with:
     [java]     at com.goldencode.p2j.pattern.PatternEngine.run(PatternEngine.java:1100)
     [java]     at com.goldencode.p2j.convert.TransformDriver.processTrees(TransformDriver.java:589)
     [java]     at com.goldencode.p2j.convert.ConversionDriver.back(ConversionDriver.java:551)
     [java]     at com.goldencode.p2j.convert.TransformDriver.executeJob(TransformDriver.java:1001)
     [java]     at com.goldencode.p2j.convert.ConversionDriver.main(ConversionDriver.java:1272)
     [java] Caused by: com.goldencode.expr.ExpressionException: Expression execution error @1:13 [DEC_LITERAL id=98784247828]
     [java]     at com.goldencode.p2j.pattern.AstWalker.walk(AstWalker.java:275)
     [java]     at com.goldencode.p2j.pattern.AstWalker.walk(AstWalker.java:210)
     [java]     at com.goldencode.p2j.pattern.PatternEngine.apply(PatternEngine.java:1692)
     [java]     at com.goldencode.p2j.pattern.PatternEngine.processAst(PatternEngine.java:1578)
     [java]     at com.goldencode.p2j.pattern.PatternEngine.processAst(PatternEngine.java:1511)
     [java]     at com.goldencode.p2j.pattern.PatternEngine.run(PatternEngine.java:1063)
     [java]     ... 4 more
     [java] Caused by: com.goldencode.expr.ExpressionException: Expression execution error @1:13
     [java]     at com.goldencode.expr.Expression.execute(Expression.java:495)
     [java]     at com.goldencode.p2j.pattern.Rule.apply(Rule.java:500)
     [java]     at com.goldencode.p2j.pattern.Rule.executeActions(Rule.java:751)
     [java]     at com.goldencode.p2j.pattern.Rule.coreProcessing(Rule.java:717)
     [java]     at com.goldencode.p2j.pattern.Rule.apply(Rule.java:537)
     [java]     at com.goldencode.p2j.pattern.RuleContainer.apply(RuleContainer.java:597)
     [java]     at com.goldencode.p2j.pattern.RuleSet.apply(RuleSet.java:98)
     [java]     at com.goldencode.p2j.pattern.AstWalker.walk(AstWalker.java:262)
     [java]     ... 9 more
     [java] Caused by: java.lang.NullPointerException
     [java]     at com.goldencode.p2j.util.ErrorManager.writeLog(ErrorManager.java:3287)
     [java]     at com.goldencode.p2j.util.ErrorManager.recordOrThrowError(ErrorManager.java:1946)
     [java]     at com.goldencode.p2j.util.ErrorManager.recordOrThrowError(ErrorManager.java:1893)
     [java]     at com.goldencode.p2j.util.ErrorManager.recordOrThrowError(ErrorManager.java:1862)
     [java]     at com.goldencode.p2j.util.ErrorManager.recordOrThrowError(ErrorManager.java:1791)
     [java]     at com.goldencode.p2j.util.ErrorManager.recordOrThrowError(ErrorManager.java:1770)
     [java]     at com.goldencode.p2j.util.NumberType.parseDecimal(NumberType.java:914)
     [java]     at com.goldencode.p2j.util.NumberType.parseDecimal(NumberType.java:701)
     [java]     at com.goldencode.p2j.util.NumberType.parseDecimal(NumberType.java:670)
     [java]     at com.goldencode.p2j.convert.ExpressionConversionWorker$ExpressionHelper.cleanDecimal(ExpressionConversionWorker.java:3634)
     [java]     at com.goldencode.expr.CE10517.execute(Unknown Source)
     [java]     at com.goldencode.expr.Expression.execute(Expression.java:398)
     [java]     ... 16 more

#3 Updated by Artur Școlnic almost 2 years ago

  • Assignee set to Artur Școlnic
  • Status changed from New to WIP

This task was derived from #9096-23.

#4 Updated by Artur Școlnic almost 2 years ago

  • Status changed from WIP to Review

I committed 9125a/15412. I limited the length of the converted decimal to 50, initially I was thinking of trimming all the trailing zeros, but limiting the length of the entire decimal seems like an easier approach. As a side note, we can't have the same decimal literal as in 4gl, because of the implicit trimming and the variable scale in the OE environment, we can either limit the total number of digits to 50 or trim all the trailing zeros.

#5 Updated by Artur Școlnic almost 2 years ago

For testing I used:

define variable v_dec as decimal.
v_dec = 4000000000000000000000000000000000000000000000.0000000000.
v_dec = 4000000000000000000000000000000000000000000000.0000000000000.
v_dec = 4000000000000000000000000000000000000000000000.0201.
v_dec = 4000000000000000000000000000000000000000000000.
v_dec = 4000000000000000000000000000000000000000000001.0000000000.

the converted code is:
vDec.assign(decimal.fromLiteral("4000000000000000000000000000000000000000000000.000"));
vDec.assign(decimal.fromLiteral("4000000000000000000000000000000000000000000000.000"));
vDec.assign(decimal.fromLiteral("4000000000000000000000000000000000000000000000.020"));
vDec.assign(decimal.fromLiteral("4000000000000000000000000000000000000000000000"));
vDec.assign(decimal.fromLiteral("4000000000000000000000000000000000000000000001.000"));

#6 Updated by Artur Școlnic almost 2 years ago

Another issue that can be discussed in this task is that decimals have a fixed scale of 10 in FWD, this causes the value (BigDecimal) to be appended with at most 10 zeros, regardless of the scale in the original (4gl) decimal. For example:

v_dec = 4000000000000000000000000000000000000000000000.0000000000. //4gl

vDec.assign(decimal.fromLiteral("4000000000000000000000000000000000000000000000.000")); //converted code

After the assign, vDec has the scale 10 and it's value is 4000000000000000000000000000000000000000000000.0000000000.
I think setting the initial scale to the one used in 4gl (with the precision limited to 50), would solve this issue.

Also available in: Atom PDF