public void UnaryOperator() { var result = CalcSimpleExpression("+ + 2"); Assert.AreEqual(2M, result); // as decimal result = CalcSimpleExpression("+ 2"); Assert.AreEqual(2M, result); // as decimal result = CalcSimpleExpression("- 2"); Assert.AreEqual(-2M, result); // as decimal result = CalcSimpleExpression("-'2'"); Assert.AreEqual(-2M, result); // as decimal result = CalcSimpleExpression("+'2'"); Assert.AreEqual(2M, result); // as decimal result = CalcSimpleExpression("-'a'"); Assert.IsTrue(NaN.IsNaN(result)); result = CalcSimpleExpression("-true"); Assert.AreEqual(-1M, result); // as decimal result = CalcSimpleExpression("+false"); Assert.AreEqual(0M, result); // as decimal result = CalcSimpleExpression("!'aaa'"); Assert.AreEqual(false, result); result = CalcSimpleExpression("!!true"); Assert.AreEqual(true, result); result = CalcSimpleExpression("!!'a'"); Assert.AreEqual(true, result); result = CalcSimpleExpression("!''"); Assert.AreEqual(true, result); }
/// <summary> /// Override equals. /// </summary> /// /// @stable ICU 2.0 public override bool Equals(Object obj) { if (obj == null) { return(false); } if ((Object)this == obj) { return(true); } DecimalFormatSymbols other = (DecimalFormatSymbols)obj; return(zeroDigit == other.zeroDigit && groupingSeparator == other.groupingSeparator && decimalSeparator == other.decimalSeparator && percent == other.percent && perMill == other.perMill && digit == other.digit && minusSign == other.minusSign && patternSeparator == other.patternSeparator && infinity.Equals(other.infinity) && NaN.Equals(other.NaN) && currencySymbol.Equals(other.currencySymbol) && intlCurrencySymbol.Equals(other.intlCurrencySymbol) && padEscape == other.padEscape && // [NEW] plusSign == other.plusSign && // [NEW] exponentSeparator.Equals(other.exponentSeparator) && // [NEW] monetarySeparator == other.monetarySeparator); }
public void TestIsCanonical() { Assert.True(Scalbn(FromInt32(314), -2).IsCanonical()); Assert.True(Scalbn(FromInt32(-314), -2).IsCanonical()); Assert.True(Zero.IsCanonical()); Assert.True(NaN.IsCanonical()); Assert.True(PositiveInfinity.IsCanonical()); Assert.True(NegativeInfinity.IsCanonical()); }
public void TestIsSubnormal() { Assert.False(Scalbn(FromInt32(314), -2).IsSubnormal()); Assert.False(Scalbn(FromInt32(-314), -2).IsSubnormal()); Assert.False(Zero.IsSubnormal()); Assert.False(NaN.IsSubnormal()); Assert.False(PositiveInfinity.IsSubnormal()); Assert.False(NegativeInfinity.IsSubnormal()); }
/// <summary> /// Compares the specified object to this DecimalFormatSymbols and answer if /// they are equal. The object must be an instance of DecimalFormatSymbols /// with the same symbols. /// </summary> /// /// <param name="object">the object to compare with this object</param> /// <returns>true if the specified object is equal to this /// DecimalFormatSymbols, false otherwise</returns> /// <seealso cref="M:System.Globalization.NumberFormatInfo.HashCode"/> public override bool Equals(Object obj0) { if ((Object)this == obj0) { return(true); } if (!(obj0 is NumberFormatInfo)) { return(false); } DecimalFormatSymbols obj = (DecimalFormatSymbols)obj0; return(ILOG.J2CsMapping.Collections.Arrays.Equals(patternChars, obj.patternChars) && infinity.Equals(obj.infinity) && NaN.Equals(obj.NaN) && currencySymbol.Equals(obj.currencySymbol) && intlCurrencySymbol.Equals(obj.intlCurrencySymbol)); }
public void AdditiveOperations() { var result = CalcSimpleExpression("2 + 2"); Assert.AreEqual(result, 4M); // as decimal result = CalcSimpleExpression("'2' + 4"); Assert.AreEqual(result, "24"); result = CalcSimpleExpression("2 + '4'"); Assert.AreEqual(result, "24"); result = CalcSimpleExpression("'aaa' + 'bbb'"); Assert.AreEqual(result, "aaabbb"); result = CalcSimpleExpression("5 - '3'"); Assert.AreEqual(result, 2M); result = CalcSimpleExpression("'5' - - 8"); Assert.AreEqual(result, 13M); result = CalcSimpleExpression("'s' - 23"); Assert.IsTrue(NaN.IsNaN(result)); }
public bool Equals(NaN other) { return !ReferenceEquals(null, other); }
public void TestToNullable() { Assert.IsTrue(NaN.ToNullable() is null); Assert.IsTrue(1d.ToNullable().HasValue); }
/// <summary> /// Answers an integer hash code for the receiver. Objects which are equal /// answer the same value for this method. /// </summary> /// /// <returns>the receiver's hash</returns> /// <seealso cref="M:System.Globalization.NumberFormatInfo.Equals(System.Object)"/> public override int GetHashCode() { return(ILOG.J2CsMapping.Util.StringUtil.NewString(patternChars).GetHashCode() + infinity.GetHashCode() + NaN.GetHashCode() + currencySymbol.GetHashCode() + intlCurrencySymbol.GetHashCode()); }