Primitive Data Type - Specific Primitive Data Types - Floating-point Numbers

Floating-point Numbers

A floating-point number represents a limited-precision rational number that may have a fractional part. These numbers are stored internally in a format equivalent to scientific notation, typically in binary but sometimes in decimal. Because floating-point numbers have limited precision, only a subset of real or rational numbers are exactly representable; other numbers can be represented only approximately.

Many languages have both a single precision (often called "float") and a double precision type.

Literals for floating point numbers include a decimal point, and typically use "e" or "E" to denote scientific notation. Examples of floating-point literals are:

  • 20.0005
  • 99.9
  • −5000.12
  • 6.02e23

Some languages (e.g., Fortran, Python, D) also have a complex number type comprising two floating-point numbers: a real part and an imaginary part.

Read more about this topic:  Primitive Data Type, Specific Primitive Data Types

Famous quotes containing the word numbers:

    One murder makes a villain, millions a hero. Numbers sanctify, my good fellow.
    Charlie Chaplin (1889–1977)