C Language

Floating Point Numbers

In C Language by Baqir AliLeave a Comment

A real or floating-point number has an integral part and a fractional part which are separated by a decimal point.

  e.g. 0.01 70.456 3e+5 .5067e-16 3.14159

Floating-point numbers can be either positive or negative and are always signed numbers. Floating point numbers can be positive or negative. There are three floating types

  • float
  • double
  • long double.

Exponential (scientific) notation can be used to represent real numbers such as 123000.0 = 1.23×105 = 1.23e5 = 1.23E5.

e or E is read as “times 10 to the power” e.g. 0.34e-4 = 0.000034 2500 = 25e2

Number Scientific Notation Exponential Notation
1000000000 1.0×109 1.0e9
123000 1.23×105 1.23e5
322.56 3.2256×102 3.2256e2
0.000056 5.6×10-5 5.6e-5

A note on floats

A suffix can be appended to a floating constant to specify its type

Suffix Type Example
F f or F float 3.7
l or L long double 3.7L

Get The Coding Examples From C Language Code Example Page

Leave a Comment