From 9294070eb1256ad7c08568d125f72e7ec5f527b2 Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Fri, 13 Oct 2017 15:41:18 +0200 Subject: [PATCH] Values, getXYValue(): support for BigRational --- prism/src/parser/Values.java | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/prism/src/parser/Values.java b/prism/src/parser/Values.java index 96aa84bb..eb18807b 100644 --- a/prism/src/parser/Values.java +++ b/prism/src/parser/Values.java @@ -241,16 +241,19 @@ public class Values implements Cloneable //implements Comparable public int getIntValue(int i) throws PrismLangException { Object o; - + o = values.get(i); - + if (o instanceof Boolean) { return ((Boolean)o).booleanValue() ? 1 : 0; } if (o instanceof Integer) { return ((Integer)o).intValue(); } - + if (o instanceof BigRational) { + return ((BigRational)o).toInt(); + } + throw new PrismLangException("Cannot get integer value for \"" + getName(i) + "\""); } @@ -273,6 +276,9 @@ public class Values implements Cloneable //implements Comparable if (o instanceof Double) { return ((Double)o).doubleValue(); } + if (o instanceof BigRational) { + return ((BigRational)o).doubleValue(); + } throw new PrismLangException("Cannot get double value for \"" + getName(i) + "\""); } @@ -283,14 +289,16 @@ public class Values implements Cloneable //implements Comparable public boolean getBooleanValue(int i) throws PrismLangException { Object o; - + o = values.get(i); - - if (!(o instanceof Boolean)) { + + if (o instanceof Boolean) { + return ((Boolean)o).booleanValue(); + } else if (o instanceof BigRational) { + return ((BigRational)o).toBoolean(); + } else { throw new PrismLangException("Cannot get boolean value for \"" + getName(i) + "\""); } - - return ((Boolean)o).booleanValue(); } /**