Programming Fundamentals/FloatingPoint Data Type
Contents
Overview[edit]
A floatingpoint data type uses a formulaic representation of real numbers as an approximation so as to support a tradeoff between range and precision. For this reason, floatingpoint computation is often found in systems which include very small and very large real numbers, which require fast processing times. A number is, in general, represented approximately to a fixed number of significant digits and scaled using an exponent in some fixed base.^{[1]}
Discussion[edit]
The floatingpoint data type is a family of data types that act alike and differ only in the size of their domains (the allowable values). The floatingpoint family of data types represents number values with fractional parts. They are technically stored as two integer values: a mantissa and an exponent. The floatingpoint family has the same attributes and acts or behaves similarly in all programming languages. They can always store negative or positive values thus they always are signed; unlike the integer data type that could be unsigned. The domain for floatingpoint data types varies because they could represent very large numbers or very small numbers. Rather than talk about the actual values, we mention the precision. The more bytes of storage the larger the mantissa and exponent, thus more precision.
Language  Reserved Word  Size  Precision  Range 

C++  float

32 bits / 4 bytes  7 decimal digits  ±3.40282347E+38 
C++  double

64 bits / 8 bytes  15 decimal digits  ±1.79769313486231570E+308 
C#  float

32 bits / 4 bytes  7 decimal digits  ±3.40282347E+38 
C#  double

32 bits / 4 bytes  15 decimal digits  ±1.79769313486231570E+308 
Java  float

32 bits / 4 bytes  7 decimal digits  ±3.40282347E+38 
Java  double

32 bits / 4 bytes  15 decimal digits  ±1.79769313486231570E+308 
JavaScript  Number

64 bits / 8 bytes  15 decimal digits  ±1.79769313486231570E+308 
Python  float()

64 bits / 8 bytes  15 decimal digits  ±1.79769313486231570E+308 
Swift  Float

32 bits / 4 bytes  7 decimal digits  ±3.40282347E+38 
Swift  Double

64 bits / 8 bytes  15 decimal digits  ±1.79769313486231570E+308 
Key Terms[edit]
 double
 The most often used floatingpoint family data type used.
 mantissa exponent
 The two integer parts of a floatingpoint value.
 precision
 The effect on the domain of floatingpoint values given a larger or smaller storage area in bytes.