/// <summary>
        /// Convert StackValue to boolean typed StackValue. Returns
        /// StackValue.Null if not able to do conversion.
        /// </summary>
        /// <param name="core"></param>
        /// <returns></returns>
        public StackValue ToBoolean(RuntimeCore runtimeCore)
        {
            switch (optype)
            {
            case AddressType.Boolean:
                return(this);

            case AddressType.Int:
                return(BuildBoolean(opdata != 0));

            case AddressType.Null:
                return(StackValue.Null);

            case AddressType.Double:
                bool b = !Double.IsNaN(DoubleValue) && !DoubleValue.Equals(0.0);
                return(BuildBoolean(b));

            case AddressType.Pointer:
                return(StackValue.BuildBoolean(true));

            case AddressType.String:
                string str = runtimeCore.RuntimeMemory.Heap.ToHeapObject <DSString>(this).Value;
                return(string.IsNullOrEmpty(str) ? StackValue.False : StackValue.True);

            case AddressType.Char:
                char c = Convert.ToChar(opdata);
                return((c == 0) ? StackValue.False : StackValue.True);

            default:
                return(StackValue.Null);
            }
        }
        public void ensureDoubleValueAndNullObjectAreNotEqual()
        {
            DoubleValue doubleValue = 21;

            DoubleValue otherDoubleValue = null;

            Assert.False(doubleValue.Equals(otherDoubleValue));
        }
        public void ensureDoubleValueAndOtherObjectTypeAreNotEqual()
        {
            DoubleValue doubleValue = 21;

            string other = "This is just a string";

            Assert.False(doubleValue.Equals(other));
        }
        public void ensureSameReferenceDoubleValuesAreEqual()
        {
            DoubleValue doubleValue = 21;

            DoubleValue otherDoubleValue = doubleValue;

            Assert.True(doubleValue.Equals(otherDoubleValue));
        }
        public void ensureDoubleValueAndDoubleAreNotEqualWhenUsingDifferentValues()
        {
            double number = 12;

            DoubleValue doubleValue = DoubleValue.valueOf(21);

            Assert.False(doubleValue.Equals(number));
        }
示例#6
0
 public bool Equals(DataModel other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Id == other.Id && StringValue == other.StringValue && DoubleValue.Equals(other.DoubleValue) && FloatValue.Equals(other.FloatValue) && BoolValue == other.BoolValue);
 }
示例#7
0
        public void Equals() // Faster: 1.02, 1, 1.01
        {
            const double zero = 0.0;

            for (var i = 0; i < NbIterations; i++)
            {
                _consumer.Consume(DoubleValue.Equals(DoubleValue));
                _consumer.Consume(DoubleValue.Equals(zero));
                _consumer.Consume(zero.Equals(zero));
                _consumer.Consume(zero.Equals(DoubleValue));
            }
        }
示例#8
0
 protected bool Equals(ClassWithAllTypes other)
 {
     return(CharValue == other.CharValue &&
            ByteValue == other.ByteValue &&
            SByteValue == other.SByteValue &&
            ShortValue == other.ShortValue &&
            UShortValue == other.UShortValue &&
            IntValue == other.IntValue &&
            UIntValue == other.UIntValue &&
            LongValue == other.LongValue &&
            ULongValue == other.ULongValue &&
            FloatValue.Equals(other.FloatValue) &&
            DoubleValue.Equals(other.DoubleValue) &&
            DecimalValue == other.DecimalValue &&
            DateTimeValue.Equals(other.DateTimeValue) &&
            GuidValue.Equals(other.GuidValue) &&
            StringValue.Equals(other.StringValue));
 }
 public bool Equals(ModelForGenerated other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(BsonObjectIdValue.Equals(other.BsonObjectIdValue) &&
            BooleanValue == other.BooleanValue &&
            DoubleValue.Equals(other.DoubleValue) &&
            StringValue == other.StringValue &&
            BsonDocumentValue.Equals(other.BsonDocumentValue) &&
            //DateTimeOffsetValue.Equals(other.DateTimeOffsetValue) &&
            //GuidValue.Equals(other.GuidValue) &&
            IntValue == other.IntValue &&
            LongValue == other.LongValue &&
            List.Equals(other.List));
 }
示例#10
0
            private void CalculateEpsilon()
            {
                if (_isEpsilonCalculated)
                {
                    return;
                }

                _isEpsilonCalculated = true;

                if (DoubleValue.Equals(0D))
                {
                    return;
                }

                if (double.IsInfinity(DoubleValue))
                {
                    return;
                }

                if (double.IsNaN(DoubleValue))
                {
                    return;
                }

                var sign  = Sign(DoubleValue);
                var value = Abs(DoubleValue);

                var order   = (int)Floor(GetOrder(value));
                var normVal = value * Exp10(-order);

                double major;
                double minor;


                while (true)
                {
                    major = Floor(normVal);
                    minor = normVal - major;
                    if (minor < 0.000001)
                    {
                        break;
                    }

                    major++;
                    minor = normVal - major;
                    if (-minor < 0.000001)
                    {
                        break;
                    }

                    order--;
                    normVal *= 10D;
                }

                var factor = sign * Exp10(order);

                _omega   = minor.Equals(0D) ? DoubleValue : major * factor;
                _epsilon = Abs(DoubleValue - Omega);
                _eps     = sign * Sign(value - Abs(Omega)) * Epsilon;
                //Epsilon = Omega.Equals(DoubleValue) ? 0 : minor*factor;
            }
示例#11
0
 protected bool Equals(Number other)
 {
     return(IsInteger == other.IsInteger && DoubleValue.Equals(other.DoubleValue) && IntValue == other.IntValue);
 }