// Limits
// Daniel Pereira, 04 November 2022.
// Use limits.h and float.h to access MIN and MIX variables.
#include <stdio.h>
#include <limits.h> // limits on integer types
#include <float.h> // limits on floating point types
int main(int argc, char* argv[])
{
printf("INTEGER TYPE, MIN, MAX.\n");
printf("-----------------------\n");
printf("char, %d, %d\n", CHAR_MIN, CHAR_MAX);
printf("unsigned char, NA, %u\n", UCHAR_MAX);
printf("short, %d, %d\n", SHRT_MIN, SHRT_MAX);
printf("unsigned short,NA,%u\n", USHRT_MAX);
printf("int, %d, %d\n", INT_MIN, INT_MAX);
printf("unsigned int, NA, %u\n", UINT_MAX);
printf("long, %ld, %ld\n", LONG_MIN, LONG_MAX);
printf("unsigned long, NA, %lu\n", ULONG_MAX);
printf("long long, %lld, %lld\n", LLONG_MIN, LLONG_MAX);
printf("unsigned long long, NA, %llu\n\n", ULLONG_MAX);
printf("FLOATING POINT TYPE, MIN, MAX.\n");
printf("------------------------------\n");
printf("Float MIN: %.3e\n", FLT_MIN);
printf("Float MAX: %.3e\n", FLT_MAX);
printf("Double MIN: %.3e\n", DBL_MIN);
printf("Double MAX: %.3e\n", DBL_MAX);
printf("Long Double MIN: %.3Le\n", LDBL_MIN);
printf("Long Double MAX: %.3Le\n", LDBL_MAX);
printf("Number of decimal digits precision of float: %u\n", FLT_DIG);
printf("Number of decimal digits precision of double: %u\n", DBL_DIG);
printf("Number of decimal digits precision of long double: %u\n", LDBL_DIG);
return 0;
}
// climits <limits.h>
// https://devdocs.io/cpp/header/climits
// This header was originally in the C standard library as <limits.h>.
//
// This header is part of the type support library, in particular it's part of the C numeric limits interface.
// <float.h>
// https://www.tutorialspoint.com/c_standard_library/float_h.htm
//
// The float.h header file of the C Standard Library contains a set of various platform-dependent constants related to floating point values. These constants are proposed by ANSI C. They allow making more portable programs.
My solution to Exercise 3-2 from Part 1, Chapter 3 of C++ Crash Course. Github: https://github.com/pereiradaniel/CPP_CRASH_COURSE/blob/master/P1C3/EXERCISES/3_2.cpp Youtube: C++ Crash Course: Solution to Exercise 3-2.
For the last while, I have been busy with ESP32 and Arduino programming, but now I finally have time to ram through this book and the exercises. There are a few repositories on Github where people have offered solutions to some of these exercises, but I find that they are often not complete. Therefore, I am endeavouring to make a more complete listing, or at least fill in some of the holes. Here is a video and a link to the repository for the solutions to Part 1, Chapter 1. The exercises can be found at the end of each chapter. I am back-tracking a bit from where I am in Part 1 Chapter 5, which is where I am currently studying. Github: https://github.com/pereiradaniel/CPP_CRASH_COURSE/tree/master/P1C1/EXERCISES Video: C++ Crash Course: Solutions to Exercises in Part 1, Chapter 1.
My solution to Exercise 3-4 from Part 1, Chapter 3 of C++ Crash Course. This one was fairly straightforward, but it illustrates a very important thing on line 13. When you assign new_value to the reference original_ref , it assigns the value to the int that original_ref is pointing to. The result is that new_value and original both have the same value, 200. Github: https://github.com/pereiradaniel/CPP_CRASH_COURSE/blob/master/P1C3/EXERCISES/3_4.cpp Youtube: C++ Crash Course: Solution to Exercise 3-4.