本文整理汇总了C#中BigDecimal.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# BigDecimal.Equals方法的具体用法?C# BigDecimal.Equals怎么用?C# BigDecimal.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigDecimal
的用法示例。
在下文中一共展示了BigDecimal.Equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equal
public static bool Equal(RubyContext/*!*/ context, BigDecimal/*!*/ self, double other) {
return self.Equals(BigDecimal.Create(GetConfig(context), other));
}
示例2: TestGetHashCode
public void TestGetHashCode()
{
// anything that is equal must have the same hashCode
BigDecimal hash = BigDecimal.Parse("1.00");
BigDecimal hash2 = new BigDecimal(1.00D);
Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
"the hashCode of 1.00 and 1.00D is equal");
hash2 = BigDecimal.Parse("1.0");
Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
"the hashCode of 1.0 and 1.00 is equal");
BigInteger val = BigInteger.Parse("100");
hash2 = new BigDecimal(val, 2);
Assert.IsTrue(hash.GetHashCode() == hash2.GetHashCode() && hash.Equals(hash2),
"hashCode of 1.00 and 1.00(bigInteger) is not equal");
hash = new BigDecimal(value, 2);
hash2 = BigDecimal.Parse("-1233456.0000");
Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
"hashCode of 123459.08 and -1233456.0000 is not equal");
hash2 = new BigDecimal(value.Negate(), 2);
Assert.IsTrue(hash.GetHashCode() != hash2.GetHashCode() && !hash.Equals(hash2),
"hashCode of 123459.08 and -123459.08 is not equal");
}
示例3: EqualsObject
public void EqualsObject()
{
BigDecimal equal1 = new BigDecimal(1.00D);
BigDecimal equal2 = BigDecimal.Parse("1.0");
Assert.IsFalse(equal1.Equals(equal2), "1.00 and 1.0 should not be equal");
equal2 = new BigDecimal(1.01D);
Assert.IsFalse(equal1.Equals(equal2), "1.00 and 1.01 should not be equal");
equal2 = BigDecimal.Parse("1.00");
Assert.IsFalse(equal1.Equals(equal2), "1.00D and 1.00 should not be equal");
BigInteger val = BigInteger.Parse("100");
equal1 = BigDecimal.Parse("1.00");
equal2 = new BigDecimal(val, 2);
Assert.IsTrue(equal1.Equals(equal2), "1.00(string) and 1.00(bigInteger) should be equal");
equal1 = new BigDecimal(100D);
equal2 = BigDecimal.Parse("2.34576");
Assert.IsFalse(equal1.Equals(equal2), "100D and 2.34576 should not be equal");
Assert.IsFalse(equal1.Equals("23415"), "bigDecimal 100D does not equal string 23415");
}