Variables Arithmetic IO

00 99 e od ba lh for more gory details see

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: >; i( <2601& x>2599 / YS GO fx .00 & .99) / E, OD { / ba.. / lh. } For more gory details, see: http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm 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 hr resorting to creating lots of c a variables. So the string " e l "is literally the collection of c a hr hlo hr thingies ' '' '' '' '' '(there is actually another special c a at the end that tells the hello hr 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). hr 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 : icue srn> tig #nld <otem icue isra> #nld <tig / ncsayt uesrns icue srn> / eesr o s tig uignmsaesd sn aepc t; itmi( n an) { srn mnm ="ohaEkoh; tig yae Jsu crt" cu < mnm < ed; ot < yae < nl rtr 0 eun ; } 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. hr. hr (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 ol Integers: i t n Floating point: d u l obe Strings: s r n tig 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.

Ask a homework question - tutors are online