static StackObject *CompareTo_2(ILIntepreter __intp, StackObject *__esp, List <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.Double value = *(double *)&ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Double 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_5(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.Double 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); }
public int CompareTo(object p_compareTo) { UnitType this_type = this.Type; if (p_compareTo.GetType() != typeof(Unit)) { return(-1); } Unit other = (Unit)p_compareTo; UnitType other_type = ((Unit)other).Type; switch (this_type) { case UnitType.Float: switch (other_type) { case UnitType.Float: return(floatValue.CompareTo(other.floatValue)); case UnitType.Integer: return(floatValue.CompareTo(other.integerValue)); case UnitType.Char: return(1); case UnitType.Null: return(1); case UnitType.Boolean: return(1); default: return(-1); } case UnitType.Integer: switch (other_type) { case UnitType.Float: if (this.integerValue > other.floatValue) { return(1); } else if (this.integerValue < other.floatValue) { return(-1); } else { return(0); } case UnitType.Integer: return(integerValue.CompareTo(other.integerValue)); case UnitType.Char: case UnitType.Null: case UnitType.Boolean: return(1); default: return(-1); } case UnitType.Char: switch (other_type) { case UnitType.Float: case UnitType.Integer: return(-1); case UnitType.Char: return(charValue.CompareTo(other.charValue)); case UnitType.Null: case UnitType.Boolean: return(1); default: return(-1); } case UnitType.Null: switch (other_type) { case UnitType.Null: return(0); default: return(-1); } case UnitType.Boolean: switch (other_type) { case UnitType.Float: case UnitType.Integer: case UnitType.Char: return(-1); case UnitType.Null: return(1); case UnitType.Boolean: return(boolValue.CompareTo(other.boolValue)); default: return(-1); } case UnitType.String: case UnitType.Table: case UnitType.List: case UnitType.Function: case UnitType.Intrinsic: case UnitType.Closure: case UnitType.UpValue: case UnitType.Module: case UnitType.Wrapper: return((this.heapUnitValue).CompareTo(p_compareTo)); default: throw new Exception("Trying to compare a Unit to unkown UnitType."); } }
private static void TestCompare(Double a, Double b) { String di = a.CompareTo(b).ToString() + ' ' + b.CompareTo(a).ToString(); BigNum na = a; BigNum nb = b; String ni = na.CompareTo(nb).ToString() + ' ' + nb.CompareTo(na).ToString(); Console.WriteLine("{0,18} comp {1,18} = {2,18} : {3,18} -> {4}", a, b, di, ni, di == ni ? "Pass" : "Fail" ); }
public static bool IsBetween(this Double @this, Double minValue, Double maxValue) { return(minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1); }
/// <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 Double @this, Double minValue, Double maxValue) { return minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Compares the current instance with another object of the same type and returns an integer /// that indicates whether the current instance precedes, follows, or occurs in the same position /// in the sort order as the other object. /// </summary> /// /// <param name="other"> An object to compare with this instance. </param> /// /// <returns> /// A value that indicates the relative order of the objects being compared. The return value has /// these meanings: Value Meaning Less than zero This instance precedes <paramref name="other" /> /// in the sort order. Zero This instance occurs in the same position in the sort order as /// <paramref name="other" />. Greater than zero This instance follows <paramref name="other" /> /// in the sort order. /// </returns> /// /// <seealso cref="M:System.IComparable{KelpNet.Common.Real}.CompareTo(Real)"/> //////////////////////////////////////////////////////////////////////////////////////////////////// public int CompareTo(Real other) { return(Value.CompareTo(other.Value)); }