APM Welcome, APM North West Network Conference, Synergies Across Sectors
More on Data Types (Exponential and Scientific Notations)
1. The Character 'n' and the String “n”
The compiler recognizes both 'n' and “n” as
containing the newline character. The difference is
in the data type used. Formally, 'n' is a character
literal, and “n” is a string literal. From a practical
standpoint, both cause the same thing to happen:
A new line is forced in the output display.
2. Good programming practice requires ending the
last output display with a newline escape
sequence. This practice ensures that the first line
of output from one program doesn’t end up on the
last line displayed by the previously executed
program.
3. A signed data type allows storing negative
values, the value 0, and positive values
An unsigned data type provides for only non-
negative values (that is, 0 and positive values).
Some applications require only unsigned numerical
values.
4. For example, many date applications store dates
in the numerical form yearmonthday (storing
12/25/2011 as 20111225, for example)
For these applications, which never require a
negative value, an unsigned data type can be
used.
5.
6. Floating-Point Types
A floating-point number, more commonly known as
a real number, can be the number 0 or any positive
or negative number containing a decimal point.
The following are examples of floating point
numbers:
+10.62 5.0 -6.2 3251.92 0.00 .33-6.67 +2.
7. A float value is sometimes referred to as a single-
precision number and a double value as a
double-precision number.
9.234 indicates a double literal.
9.234F indicates a float literal.
9.234L indicates a long double literal.
8. What is precision?
In numerical theory, the term precision typically
refers to numerical accuracy.
9. “This computation is accurate, or precise, to the
fifth decimal place” means the fifth digit after the
decimal point has been rounded, and the number
is accurate to within ±0.00005.
10. 687.45678921 has five significant digits therefore; its
accurate to have the value 687.46. The last digit
assumed to be rounded.
11. In computer programming, “precision” can refer to
a number’s accuracy or the number of significant
digits; significant digits are defined as the number
of clearly correct digits plus 1.
13. Exponential Notation
Floating-point numbers can also be written in
exponential notation, which is similar to scientific
notation and is commonly used to express both very
large and very small values in compact form. The
following examples show how numbers with
decimals can be expressed in exponential and
scientific notation: