< Summary - SonghayCore

Information
Class: Songhay.MathUtility
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/MathUtility.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 44
Line coverage: 100%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
GetDigitInNumber(...)50%2100%
GetMantissa(...)50%2100%
TruncateNumber(...)50%2100%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/MathUtility.cs

#LineLine coverage
 1namespace Songhay;
 2
 3/// <summary>
 4/// Static helpers for Math.
 5/// </summary>
 6public static class MathUtility
 7{
 8    /// <summary>
 9    /// Gets the digit in number.
 10    /// </summary>
 11    /// <param name="x">The x.</param>
 12    /// <param name="place">The place (from right to left).</param>
 13    public static byte? GetDigitInNumber(int x, int place)
 914    {
 915        var d = (int) Math.Pow(10, place - 1);
 916        if (d < 0) return null;
 17
 918        return Convert.ToByte((x / d) % 10);
 919    }
 20
 21    /// <summary>
 22    /// Gets the mantissa.
 23    /// </summary>
 24    /// <param name="x">The x.</param>
 25    /// <param name="round">The round.</param>
 26    public static double GetMantissa(double x, int round)
 227    {
 228        double mantissaValue = (x < 0 ? -1 : 1) *
 229                               (Math.Abs(x) - Math.Floor(Math.Abs(x)));
 30
 231        mantissaValue = Math.Round(mantissaValue, round);
 32
 233        return mantissaValue;
 234    }
 35
 36    /// <summary>
 37    /// Truncates the number.
 38    /// </summary>
 39    /// <param name="x">The x.</param>
 40    /// <remarks>
 41    /// Silverlight does not have <c>Math.Truncate()</c>.
 42    /// </remarks>
 243    public static double TruncateNumber(double x) => (x < 0 ? -1 : 1) * Math.Floor(Math.Abs(x));
 44}