- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Extended Integral Types (Choosing the correct integer size in C/C++)
In this tutorial, we will be discussing a program to understand extended integral types in C/C++.
The data types in C are very loosely defined. Their range values changes on the basis of the compiler being 32 or 64 bit. To specify the compiler range you want to use in your program we use intN_t.
Example
#include <iostream> using namespace std; int main(){ uint8_t i; //mentioning the bit to be 8 i = 0; cout << "Minimum value of i\t: "<<< (int)i << endl; i = 255; cout << "Maximum value of i\t: "<< (int)i << endl; //moving beyond the given bit will result in garbage value i = 2436; cout << "Beyond range value of i\t: " << (int)i << endl; return 0; }
Output
Minimum value of i : 0 Maximum value of i : 255 Beyond range value of i : 132
Advertisements