Пример #1
0
        public void Number_Absolute_Value_Should_Have_Expected_Value(double doubleNumber, double expectedAbsoluteValue)
        {
            // Arrange
            var number = _calculator.FromDouble(doubleNumber);

            // Act
            var absoluteValue = _calculator.Abs(number);

            // Assert
            absoluteValue.Should().Be(expectedAbsoluteValue);
        }
Пример #2
0
        public static bool AreClose <TAlgebraicNumber>(
            this IAlgebraicNumberCalculator <TAlgebraicNumber> calculator,
            TAlgebraicNumber number1,
            TAlgebraicNumber number2,
            TAlgebraicNumber tolerance)
        {
            if (calculator is null)
            {
                throw new ArgumentNullException(nameof(calculator));
            }

            var absoluteDifference = calculator.Abs(calculator.Subtract(number2, number1));

            return(calculator.IsSmallerThan(absoluteDifference, tolerance));
        }