/// <summary> /// Finds the least common multiple of two Integers. /// </summary> /// <param name="left">The first value.</param> /// <param name="right">The second value.</param> /// <returns>The least common multiple of left and right.</returns> public static Integer Lcm(this Integer left, Integer right) { return(Abs(left * right) / Gcd(left, right)); }
/// <summary> /// Returns the larger of two Integers. /// </summary> /// <param name="left">The first value to compare.</param> /// <param name="right">The second value to compare.</param> /// <returns> /// The left or right parameter, whichever is larger. /// </returns> public static Integer Max(this Integer left, Integer right) { return(left < right ? right : left); }
/// <summary> /// Gets the absolute value of an Integer. /// </summary> /// <param name="value">The Integer.</param> /// <returns>The absolute value of the Integer.</returns> public static Integer Abs(this Integer value) { return(value < 0 ? -value : value); }
/// <summary> /// Returns the smaller of two Integers. /// </summary> /// <param name="left">The first value to compare.</param> /// <param name="right">The second value to compare.</param> /// <returns> /// The left or right parameter, whichever is smaller. /// </returns> public static Integer Min(this Integer left, Integer right) { return(left < right ? left : right); }
/// <summary> /// Gets a number that indicates the sign of an Integer. /// </summary> /// <param name="value">The Integer.</param> /// <returns>A number that indicates the sign of the Integer.</returns> public static int Sgn(this Integer value) { return(value.CompareTo(0)); }