CS 70

Exploring C++'s Numeric Types

In this week's lessons you learned about how numbers are represented in C++.

In this part you'll be able to actually see how different types are represented in the server's development environment.

show-rep and show-types

In the Types-and-Representations directory, we've provided two C++ programs that provide some details about the inner workings of the C++ system you're using. The source for these programs, show-rep.cpp and show-types.cpp, isn't something you need to go spelunking into—providing under-the-hood information necessarily involves some rather atypical C++ code and you won't gain much from peering at it. But you can take a peek if you like—the main function, at least, is mostly comprehensible. By the end of the semester, you'll understand a lot more and you'll be in a good position to figure out or look up the rest!

For now, just compile and run these programs. We've simplified the compilation process this time, so all you have to type is

make

and both programs will be compiled. (You'll learn about make later this semester!)

To run them, you can type

./show-types | more

and

./show-rep | more

The | more part stops the output from just zooming past on the screen. With more, you can page through the results by using the space bar to move forward one page at a time.

Explore the output to get a sense of how numbers are represented on this system!

Some Questions

Some of the written questions for this homework (in this Gradescope assignment) relate to this example.

Now might be a good time to answer them! (You can answer some questions, save your responses, and then go back and answer the rest later.)

To Complete This Part of the Assignment…

You'll know you're done with this part of the assignment when you've done all of the following:

(When logged in, completion status appears here.)