In 32-bit and 64-bit systems, the length of main types of C ++ is compared, 32-bit 64-bit

Source: Internet
Author: User
Tags comparison table

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  


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.