internal static IDynamic Max(IEnvironment environment, IArgs args) { if (args.IsEmpty) { return(environment.CreateNumber(double.NegativeInfinity)); } if (args.Count == 1) { return(args[0].ConvertToNumber()); } var numbers = new INumber[args.Count]; for (int i = 0; i < numbers.Length; i++) { var number = args[i].ConvertToNumber(); if (double.IsNaN(number.BaseValue)) { return(environment.CreateNumber(double.NaN)); } numbers[i] = number; } INumber r = null; foreach (var n in numbers) { if (r == null || r.Op_Lessthan(n).ConvertToBoolean().BaseValue) { r = n; } } return(r); }