{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

show_nitty_gritty

show_nitty_gritty - CHAPTER 2"Simple C Programs The...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
CHAPTER 2 “Simple” C++ Programs The Nitty-Gritty March 28, 2008
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Reading Assignment Read the math function descriptions §2.8, pp 61–66.
Image of page 2
Nitty-Gritty Variables, Identifiers, Types Variables Fundamental types (everything except string ) have random values if they are not initialized when declared. 1 i n t I n t e g e r ; 2 double Double ; 3 s t r i n g S t r i n g ; 4 5 cout << "Integer =" << I n t e g e r << endl ; 6 cout << "Double =" << Double << endl ; 7 cout << "String =’" << S t r i n g << "’" << endl ; Integer=0 Double=0 String=’’ R UN E DIT garbage_variables.cxx Variable Names Identifiers
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Nitty-Gritty Variables, Identifiers, Types Beware the Reserved Words asm auto break case catch char class const continue default delete do double else enum extern float for friend goto if inline int long new operator private protected public register return short signed sizeof static struct switch template this throw try typedef union unsigned virtual void volatile while
Image of page 4
Nitty-Gritty Variables, Identifiers, Types Fundamental Type Specifiers Values for Intel PC 32b Architectures Type Specifier Bytes (Bits) Negative Range Positive Range bool 1 (1) - 0 - 1 char 1 (8) -128 - 0 0 - 127 unsigned char 1 (8) - 0 - 255 short 2 (16) -32,768 - 0 0 - 32,767 unsigned short 2 (16) - 0 - 65,535 ( int ) long 4 (32) -2,147,483,648 - 0 0 - 2,147,483,647 unsigned long 4 (32) - 0 - 4,294,967,295 float 8 (64) - 3 . 4028 × 10 38 - - 1 . 1755 × 10 - 38 1 . 1755 × 10 - 38 - 3 . 4028 × 10 38 long double 16 (128) - 2 . 2251 × 10 308 - - 1 . 7977 × 10 - 308 1 . 7977 × 10 - 308 - 2 . 2251 × 10 308 float s and double s may also be zero. float s have 6 digits of decimal precision (6 significant digits) double s have 15 digits of decimal precision (15 significant digits) On a 64b machine, a signed int ranges through [ - 9223372036854775808 , 9223372036854775807 ]
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Nitty-Gritty Computation Headaches Underflow & Overflow Type Specifier Positive Range double 1 . 7977 × 10 - 308 - 2 . 2251 × 10 308 Underflow : You cannot compute 1 . 0 × 10 - 308 10 = 1 × 10 - 309 Overflow : You cannot compute 10 ˙ ( 2 × 10 308 ) = 2 × 10 309
Image of page 6
Nitty-Gritty Computation Headaches Integer Computations Type Specifier Positive Range int 0 - 2,147,483,647 1 / /
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern