Question:
If you are running on a 64 bit machine and you are compiling a program wouldn't an int be 64 bits?
yea...ok
2011-09-07 20:27:52 UTC
I have a 64 bit machine however I am compiling a program and when i do a bit shift on an (int b = 1) over 32 times it gives me a warning that I have shifted it past the width of the int. Shouldn't it be able to shift 63 times since an int would be 8 bytes?
Four answers:
anonymous
2011-09-07 20:46:34 UTC
It depends on one of three things:



    Programming Language

    Compiler

    Operating System



Programming Language comes first because some languages such as Java have standards compliance for its compilers. The Java Virtual machine will expect int to be 32 bits regardless of platform, int will always be 32 bits - this is defined in the Language.



Compiler comes second because there are some programming languages like C++ whose compilers can vary and are free to change certain aspects such as data type sizes. Microsoft Visual Studio for example allows you to set the platform you want to target under the Build menu in the Configuration Manager



Operating System comes last as certain Operating Systems do not support the alternate platform. e.g. 32 bit Windows can only run 32 bit programs, some 64 bit OS can only run 64 bit programs. Windows 64 bit can run 32 bit programs using some special native emulation work arounds you should normally be oblivious to, but not all OS have this functionality.
samofcalifornia
2011-09-07 20:47:05 UTC
You should look at the documentation for your compiler. For example the Microsoft C++ compiler uses 4 bytes for an int regardless of the target.
CP
2011-09-07 20:33:29 UTC
You need to check the specs for your compiler, and what the range of an int is for it.

It really depends on how many bytes are allocated for a particular data type by the compiler.
?
2011-09-07 20:33:13 UTC
No, because that's a function of the compiler. It has nothing to do with whether or not the OS is 64 or 32 bits.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...