Even better equality checking

This commit is contained in:
2018-12-09 13:47:13 +01:00
parent 6e960e38ff
commit b63e8d37b5
7 changed files with 32 additions and 1 deletions

View File

@@ -102,6 +102,15 @@ namespace Upsilon.BaseTypes.Number
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (IsFloat && obj is double d)
{
return Math.Abs(((ScriptNumberDouble) this).Value - d) < 0.0000001;
}
if (!IsFloat && obj is long l)
{
return ((ScriptNumberLong) this).Value == l;
}
if (obj.GetType() != this.GetType()) return false;
return Equals((ScriptNumber) obj);
}