/// <summary> /// Compares the current object with another object of the same type. /// </summary> /// <returns> /// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: /// Value /// Meaning /// Less than zero /// This object is less than the <paramref name="other"/> parameter. /// Zero /// This object is equal to <paramref name="other"/>. /// Greater than zero /// This object is greater than <paramref name="other"/>. /// </returns> /// <param name="other">An object to compare with this object.</param> public int CompareTo(IMeasure <Q> other) { if (other == null) { throw new ArgumentNullException("other"); } return(mAmount.CompareTo(other.GetAmount(mUnit))); }
static StackObject *CompareTo_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Single value = *(float *)&ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Single instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack); var result_of_this_method = instance_of_this_method.CompareTo(value); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
static StackObject *CompareTo_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Object value = (System.Object) typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Single instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack); var result_of_this_method = instance_of_this_method.CompareTo(value); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
/// <summary> /// Compares the current object with another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings: /// Value Meaning /// Less than zero This object is less than the <paramref name="other"/> parameter. /// Zero This object is equal to <paramref name="other"/>. /// Greater than zero This object is greater than <paramref name="other"/>. /// </returns> public int CompareTo(StandardMeasure <Q> other) { return(mAmount.CompareTo(other.mAmount)); }
/// <summary> /// A T extension method that check if the value is between (exclusif) the minValue and maxValue. /// </summary> /// <param name="this">The @this to act on.</param> /// <param name="minValue">The minimum value.</param> /// <param name="maxValue">The maximum value.</param> /// <returns>true if the value is between the minValue and maxValue, otherwise false.</returns> /// ### /// <typeparam name="T">Generic type parameter.</typeparam> public static bool Between(this Single @this, Single minValue, Single maxValue) { return minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1; }
private static Int32 Compare(Single value1, String value2) { if (String.IsNullOrEmpty(value2)) return value1.CompareTo(0.0f); if (Boolean.TrueString.Equals(value2, StringComparison.OrdinalIgnoreCase)) return value1 >= MinTrueSingle ? 0 : -1; if (Boolean.FalseString.Equals(value2, StringComparison.OrdinalIgnoreCase)) return value1 >= MinTrueSingle ? +1 : 0; Single parsedSingleValue; if (Single.TryParse(value2, out parsedSingleValue)) return value1.CompareTo(parsedSingleValue); var stringLength = value2.Length; return value1.CompareTo(stringLength); }
private static void AssertComparison(Single value1, Single value2) { var expectedComparisonResult = value1.CompareTo(value2); AssertComparison(new DataObjectValue(value1), new DataObjectValue(value2), expectedComparisonResult); }