public Int32 CompareTo(Money other) { checkCurrencies(other); int unitCompare = _units.CompareTo(other._units); return(unitCompare == 0 ? _decimalFraction.CompareTo(other._decimalFraction) : unitCompare); }
static StackObject *CompareTo_1(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.Int64 value = *(long *)&ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Int64 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.Int64 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 string SolveB() { var lines = File.ReadAllLines(Input, Encoding.UTF8); var program = Intcode.ParseInput(lines[0]); program[0] = 2; var state = new Intcode.State(program); var outputs = new List <IntType>(); IntType score = 0; IntType paddlePos = 0; IntType ballPos = 0; while (Intcode.Step(state)) { var output = state.PopOutput(); if (output.HasValue) { outputs.Add(output.Value); if (outputs.Count == 3) { var x = outputs[0]; var y = outputs[1]; var other = outputs[2]; if (x == -1 && y == 0) { score = other; } else if (other == (IntType)Tile.Paddle) { paddlePos = x; } else if (other == (IntType)Tile.Ball) { ballPos = x; } // -1, 0, 1 for movement based on ball, paddle position. state.input = ballPos.CompareTo(paddlePos); outputs.Clear(); } } } return(score.ToString()); }
private static int DateTimeComparer(Int64 a, Int64 b) { return b.CompareTo(a); }
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."); } }
public Int32 CompareTo(MoneyWholeNumber other) { var unitCompare = _units.CompareTo(other._units); return(unitCompare); }
/// <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 Int64 @this, Int64 minValue, Int64 maxValue) { return minValue.CompareTo(@this) == -1 && @this.CompareTo(maxValue) == -1; }