What are floating point literals in C#?


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

Updated on: 20-Jun-2020

731 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements