Skip to content
Snippets Groups Projects
Commit c025f321 authored by Jan Gruteser's avatar Jan Gruteser
Browse files

improve computation of the value of numeral and decimal nodes

parent 6732ab31
Branches
Tags
No related merge requests found
Pipeline #148236 passed
...@@ -523,11 +523,15 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals, BBuil ...@@ -523,11 +523,15 @@ public class BAstCreator extends BuiltInOPs implements TranslationGlobals, BBuil
case OpApplKind: case OpApplKind:
return visitOpApplNodeExpression((OpApplNode) exprNode); return visitOpApplNodeExpression((OpApplNode) exprNode);
case NumeralKind: { case NumeralKind: {
String number = String.valueOf(((NumeralNode) exprNode).val()); NumeralNode node = (NumeralNode) exprNode;
String number = String.valueOf(node.useVal() ? node.val() : node.bigVal());
return createPositionedNode(new AIntegerExpression(new TIntegerLiteral(number)), exprNode); return createPositionedNode(new AIntegerExpression(new TIntegerLiteral(number)), exprNode);
} }
case DecimalKind: { case DecimalKind: {
return createPositionedNode(new ARealExpression(new TRealLiteral(exprNode.toString())), exprNode); DecimalNode node = (DecimalNode) exprNode;
String number = String.valueOf(node.bigVal() == null ? node.mantissa() * Math.pow(10,node.exponent()) : node.bigVal());
// the image of BigDecimal should always be with .0, because the node would not have been of DecimalKind otherwise
return createPositionedNode(new ARealExpression(new TRealLiteral(number)), exprNode);
} }
case StringKind: { case StringKind: {
StringNode s = (StringNode) exprNode; StringNode s = (StringNode) exprNode;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment