Use Remainder Operator on float point data type : float « Data Type « C# / CSharp Tutorial






using System;

class MainClass
{
   static void Main()
   {
      Console.WriteLine("0.0f % 1.3f is {0}", 0.0f % 1.3f);
      Console.WriteLine("0.3f % 1.3f is {0}", 0.3f % 1.3f);
      Console.WriteLine("1.0f % 1.3f is {0}", 1.0f % 1.3f);
      Console.WriteLine("1.3f % 1.3f is {0}", 1.3f % 1.3f);
      Console.WriteLine("2.0f % 1.3f is {0}", 2.0f % 1.3f);
      Console.WriteLine("2.3f % 1.3f is {0}", 2.3f % 1.3f);
   }
}
0.0f % 1.3f is 0
0.3f % 1.3f is 0.3
1.0f % 1.3f is 1
1.3f % 1.3f is 0
2.0f % 1.3f is 0.7
2.3f % 1.3f is 1








2.25.float
2.25.1.Float Literals
2.25.2.Use Remainder Operator on float point data type
2.25.3.floats and arithmetic operators
2.25.4.Pass float to a function