What are floating point literals in C#?

CsharpProgrammingServer Side Programming

A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form.

The following are some of the examples of floating point literals −

9.23456
269485E-5F

Let us now print the floating point literals −

Example

 Live Demo

using System;

namespace Demo {

   class Program {

      static void Main(string[] args) {

         // float
         float a = 3.56f;
         Console.WriteLine(a);
         // float
         float b = 3.14159f;
         Console.WriteLine(b);
      }
   }
}

Output

3.56
3.14159
raja
Published on 10-Aug-2018 10:46:54
Advertisements