Use Remainder Operator on float point data type in CSharp

Description

The following code shows how to use Remainder Operator on float point data type.

Example


using System;//from   w ww.j  a v  a2s  . c o m

public 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);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var