In 32-bit and 64-bit systems, the length of main types of C ++ is compared, 32-bit 64-bit
Comparison of C ++ Main Types in 32-bit and 64-bit Systems 1. Source Code
#include
using namespace std;int main(int argc, const char * argv[]){ cout << "sizeof(char) = " << sizeof(char) << endl; cout << "sizeof(short) = " << sizeof(short) << endl; cout << "sizeof(int) = " << sizeof(int) << endl; cout << "sizeof(float) = " << sizeof(float) << endl; cout << "sizeof(long) = " << sizeof(long) << endl; cout << "sizeof(void *) = " << sizeof(void *) << endl; cout << "sizeof(long long) = " << sizeof(long long) << endl; cout << "sizeof(double) = " << sizeof(double) << endl; return 0;}
2. 32-bit System
Macos System (Version: 10.13.2)
Compiler: clang ++
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.3.0)
Compilation option:-arch i386
sizeof(char) = 1sizeof(short) = 2sizeof(int) = 4sizeof(float) = 4sizeof(long) = 4sizeof(void *) = 4sizeof(long long) = 8sizeof(double) = 8
3. 64-bit System
Macos System (Version: 10.13.2)
Compiler: clang ++
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.3.0)
Compilation option:-arch x86_64
sizeof(char) = 1sizeof(short) = 2sizeof(int) = 4sizeof(float) = 4sizeof(long) = 8sizeof(void *) = 8sizeof(long long) = 8sizeof(double) = 8
4. Length comparison table
Comparison between 32-bit and 64-bit System Types
Type |
32-bit system length |
64-bit system length |
Description |
Char |
1 |
1 |
|
Short |
2 |
2 |
|
Int |
4 |
4 |
|
Float |
4 |
4 |
|
Long |
4 |
8 |
Long TYPE: 32-bit System 4-byte, 64-bit system 8-byte |
Void * |
4 |
8 |
Pointer type: 32-bit System 4-byte, 64-bit system 8-byte |
Long |
8 |
8 |
|
Double |
8 |
8 |
|