Monday, 31 December 2012

Floating Point Numbers

They express numbers with decimals and/or exponents. They can include either a decimal point, an e character
(that expresses "by ten at the Xth height", where Xis an integer value that follows the e character), or both a decimal point and an e character:



These are four valid numbers with decimals expressed in C++. The first number is PI, the second one is the
number of Avogadro, the third is the electric charge of an electron (an extremely small number) -all of them
approximated- and the last one is the number three expressed as a floating-point numeric literal.


The default type for floating point literals is double. If you explicitly want to express a float or long double
numerical literal, you can use the for l suffixes respectively:



Any of the letters that can be part of a floating-point numerical constant (e, f, l) can be written using either lower
or uppercase letters without any difference in their meanings.



No comments:

Post a Comment