Created
May 12, 2012 04:49
-
-
Save larryv/2664201 to your computer and use it in GitHub Desktop.
Chapter 4, Exercise 5 from Stroustrup's "The C++ Programming Language"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
"The C++ Programming Language", Special Edition | |
Chapter 4, "Types and Declarations" | |
Exercise 5 | |
"What, on your system, are the largest and the smallest values of the | |
following types: char, short, int, long, float, double, long double, and | |
unsigned." | |
12 May 2012 | |
*/ | |
#include <iostream> | |
#include <limits> | |
int main() | |
{ | |
printf("%11s%25s%25s\n", "TYPE", "MIN", "MAX"); | |
printf("%11s%25hhd%25hhd\n", "char", | |
std::numeric_limits<char>::min(), | |
std::numeric_limits<char>::max()); | |
printf("%11s%25hd%25hd\n", "short", | |
std::numeric_limits<short>::min(), | |
std::numeric_limits<short>::max()); | |
printf("%11s%25d%25d\n", "int", | |
std::numeric_limits<int>::min(), | |
std::numeric_limits<int>::max()); | |
printf("%11s%25ld%25ld\n", "long", | |
std::numeric_limits<long>::min(), | |
std::numeric_limits<long>::max()); | |
printf("%11s%25e%25e\n", "float", | |
std::numeric_limits<float>::min(), | |
std::numeric_limits<float>::max()); | |
printf("%11s%25e%25e\n", "double", | |
std::numeric_limits<double>::min(), | |
std::numeric_limits<double>::max()); | |
printf("%11s%25Le%25Le\n", "long double", | |
std::numeric_limits<long double>::min(), | |
std::numeric_limits<long double>::max()); | |
printf("%11s%25u%25u\n", "unsigned", | |
std::numeric_limits<unsigned>::min(), | |
std::numeric_limits<unsigned>::max()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment