public void FromStringPositive() { var v = BigDec.FromString("1.5"); Assert.AreEqual(-1, v.Exponent); Assert.AreEqual(new BigInteger(15.0), v.Mantissa); }
public void LiteralReal() { var constant = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real var constant2 = new LiteralExpr(Token.NoToken, BigDec.FromString("11.7")); // Real Assert.AreNotSame(constant, constant2); // These are different references Assert.IsTrue(constant.Equals(constant2)); // These are "structurally equal" Assert.AreEqual(constant.GetHashCode(), constant2.GetHashCode()); // If the .Equals() is true then hash codes must be the same }
public void FromStringNegative() { // This tests for a Bug in Boogie that used to be present where BigDec // would not parse strings with negative numbers correctly // // If this bug is present this test will fail when checking the mantissa var v = BigDec.FromString("-1.5"); Assert.AreEqual(-1, v.Exponent); Assert.AreEqual(new BigInteger(-15.0), v.Mantissa); }
public void FloorAndCeil(string value, int expectedFloor, int expectedCeiling) { var v = BigDec.FromString(value); if (value.StartsWith("-")) { Assert.IsTrue(v.IsNegative); } else { Assert.IsTrue(v.IsPositive || v.IsZero); } BigInteger floor = 0; BigInteger ceiling = 0; v.FloorCeiling(out floor, out ceiling); Assert.AreEqual(new BigInteger(expectedFloor), floor); Assert.AreEqual(new BigInteger(expectedCeiling), ceiling); }
public override LiteralExpr ConstantReal(string value) { return(this.ConstantReal(BigDec.FromString(value))); }
public LiteralExpr ConstantReal(string value) { return(new LiteralExpr(Token.NoToken, BigDec.FromString(value), Immutable)); }
public void testReal(bool useStringInterface) { var ccB = new ConstantCachingExprBuilder(this.GetSimpleBuilder()); for (BigDec value = BigDec.FromInt(-20); value <= BigDec.FromInt(20); value += BigDec.FromString("0.1")) { var asString = value.ToString(); var realExpr = useStringInterface ? ccB.ConstantReal(asString) : ccB.ConstantReal(value); var realExpr2 = useStringInterface ? ccB.ConstantReal(asString) : ccB.ConstantReal(value); Assert.AreSame(realExpr, realExpr2); } }