Bug 521951 Real divide by zero in fUML should not return "infinity"
Change-Id: I41aab6c4797b0d45f42afa733c9c91716035e85a
Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr>
diff --git a/bundles/core/libraries/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/real/Div.java b/bundles/core/libraries/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/real/Div.java
index 11202d9..d9e8432 100644
--- a/bundles/core/libraries/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/real/Div.java
+++ b/bundles/core/libraries/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/real/Div.java
@@ -28,12 +28,14 @@
try {
Double x = ((RealValue) inputParameters.get(0).getValues().get(0)).value;
Double y = ((RealValue) inputParameters.get(1).getValues().get(0)).value;
- RealValue result = new RealValue();
- result.value = x / y;
- result.type = (PrimitiveType) this.locus.getFactory().getBuiltInType("Real");
- List<IValue> outputs = new ArrayList<IValue>();
- outputs.add(result);
- outputParameters.get(0).setValues(outputs);
+ if(y != 0) {
+ RealValue result = new RealValue();
+ result.value = x / y;
+ result.type = (PrimitiveType) this.locus.getFactory().getBuiltInType("Real");
+ List<IValue> outputs = new ArrayList<IValue>();
+ outputs.add(result);
+ outputParameters.get(0).setValues(outputs);
+ }
} catch (Exception e) {
Activator.log.error("An error occured during the execution of Div " + e.getMessage(), e);
}