< Summary

Information
Class: MoreStructures.Utilities.NumericUtilities
Assembly: MoreStructures
File(s): /home/runner/work/MoreStructures/MoreStructures/MoreStructures/Utilities/NumericUtilities.cs
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 20
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
Middle(...)100%1100%

File(s)

/home/runner/work/MoreStructures/MoreStructures/MoreStructures/Utilities/NumericUtilities.cs

#LineLine coverage
 1namespace MoreStructures.Utilities;
 2
 3/// <summary>
 4/// Generic utilities and extensions for strings.
 5/// </summary>
 6public static class NumericUtilities
 7{
 8    /// <summary>
 9    /// Returns the middle point of the provided <paramref name="interval"/>.
 10    /// </summary>
 11    /// <param name="interval">A 1D interval, identified by a lower and an upper extreme.</param>
 12    /// <returns>The middle point of the interval.</returns>
 13    /// <remarks>
 14    /// Uses the geometric interpretation of middle point to avoid int overflow, when the sum of the lower and the
 15    /// upper extremes goes above <see cref="int.MaxValue"/> or below <see cref="int.MinValue"/>.
 16    /// </remarks>
 17    public static int Middle(this (int lower, int higher) interval) =>
 537918        interval.lower + (interval.higher - interval.lower) / 2;
 19
 20}