Unformatted text preview: >;
i( <2601& x>2599 / YS GO
.99) / E, OD
} For more gory details, see:
http://en.wikipedia.org/wiki/Floating_point String types
A "string" is literally a collection of characters (c a ). C++ allows us to type strings without
resorting to creating lots of c a variables. So the string " e l "is literally the collection of c a
thingies ' '' '' '' '' '(there is actually another special c a at the end that tells the
computer the string is finished). The double-quotes "tell C++ we are using a string; single quotes '
tell C++ we are referring to a c a (which is only one thing, one symbol).
Before C++, in the C language, strings, as we use them in C++, were not available. C++-style
strings are much more convenient because you can easily make them larger or smaller, ask how
long they are, etc.
To use strings, you have to # n l d < t i g Here is an example using a s r n :
#nld <tig / ncsayt uesrns
icue srn> / eesr o s tig
sn aepc t;
srn mnm ="ohaEkoh;
cu < mnm < ed;
ot < yae < nl
} Commonly-used types
Although you may know your program has variables that would work just fine as type s o t(for
hr example), it's not always the best idea to use s o t The type s o tis relatively uncommon.
(Think about metric units: although you could use centiliters, it's normal to switch to milliliters at
that point.) The common types (and what you are encouraged to use) are:
True/False values: b o
Integers: i t
Floating point: d u l
Strings: s r n
Even with these large ranges of values, sometimes your variables may suffer overflow or
underflow. Overflow occurs when you try to store a value that is too large for the type. Underflow
occurs when you try to store a value that is too small for the type. Underflow only makes sense
with decimal types: if you try to store...
View Full Document
This note was uploaded on 05/23/2013 for the course CSE 202 taught by Professor Staff during the Winter '12 term at Ohio State.
- Winter '12