private static object Combin(List <Expression> p) { Int32 n = (int)p[0]; Int32 k = (int)p[1]; return(XLMath.Combin(n, k)); }
private static object CombinA(List <Expression> p) { Int32 number = (int)p[0]; // casting truncates towards 0 as specified Int32 chosen = (int)p[1]; if (number < 0 || number < chosen) { throw new NumberException(); } if (chosen < 0) { throw new NumberException(); } int n = number + chosen - 1; int k = number - 1; return(n == k || k == 0 ? 1 : (long)XLMath.Combin(n, k)); }
private static object Combin(List <Expression> p) { Int32 n; Int32 k; var rawN = p[0].Evaluate(); var rawK = p[1].Evaluate(); if (rawN is long || rawN is int || rawN is byte || rawN is double || rawN is float) { n = (int)Math.Floor((double)rawN); } else { throw new NumberException(); } if (rawK is long || rawK is int || rawK is byte || rawK is double || rawK is float) { k = (int)Math.Floor((double)rawK); } else { throw new NumberException(); } n = (int)p[0]; k = (int)p[1]; if (n < 0 || n < k || k < 0) { throw new NumberException(); } return(XLMath.Combin(n, k)); }