Floating point types
C# supports 2 floating point types viz. float and double.
Type # Floating type Data Type Default Value Range
1 float 32-bit single-precision IEEE 754 format 0.0f 1.5 * 10-45 to 3.4 * 1038
2 double 64-bit double-precision IEEE 754 format 0.0d 5.0 * 10-324 to 1.7 * 10308
Table – Floating point types
// Example for floating point types
using System;
class float_types
{
public static void Main(string[] args)
{
float f = 12345.12545f;
double d = 123456789.123456789d;
Console.WriteLine("Float value: " + f);
Console.WriteLine("Double value: " + d);
}
}
Output:
Float value:12345.13
Double value: 123456789.123457
No comments :
Post a Comment