本文整理匯總了C#中System.Math.IEEERemainder方法的典型用法代碼示例。如果您正苦於以下問題:C# Math.IEEERemainder方法的具體用法?C# Math.IEEERemainder怎麽用?C# Math.IEEERemainder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Math
的用法示例。
在下文中一共展示了Math.IEEERemainder方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
public class Example
{
public static void Main()
{
Console.WriteLine($"{"IEEERemainder",35} {"Remainder operator",20}");
ShowRemainders(3, 2);
ShowRemainders(4, 2);
ShowRemainders(10, 3);
ShowRemainders(11, 3);
ShowRemainders(27, 4);
ShowRemainders(28, 5);
ShowRemainders(17.8, 4);
ShowRemainders(17.8, 4.1);
ShowRemainders(-16.3, 4.1);
ShowRemainders(17.8, -4.1);
ShowRemainders(-17.8, -4.1);
}
private static void ShowRemainders(double number1, double number2)
{
var formula = $"{number1} / {number2} = ";
var ieeeRemainder = Math.IEEERemainder(number1, number2);
var remainder = number1 % number2;
Console.WriteLine($"{formula,-16} {ieeeRemainder,18} {remainder,20}");
}
}
輸出:
IEEERemainder Remainder operator 3 / 2 = -1 1 4 / 2 = 0 0 10 / 3 = 1 1 11 / 3 = -1 2 27 / 4 = -1 3 28 / 5 = -2 3 17.8 / 4 = 1.8 1.8 17.8 / 4.1 = 1.4 1.4 -16.3 / 4.1 = 0.0999999999999979 -4 17.8 / -4.1 = 1.4 1.4 -17.8 / -4.1 = -1.4 -1.4