What is the size of an integer?
-
Probably i would preffer to say implementation dependent then processor dependent . :cool: Vikas Amin Embin Technology Bombay vikas.amin@embin.com
-
Processor dependent ????? :confused: Vikas Amin Embin Technology Bombay vikas.amin@embin.com
vikas amin wrote:
Processor dependent ?????
In continuation with Mr. Prakash.. if you see := sizeof(long)==sizeof(int) in windows enviornment
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
Probably i would preffer to say implementation dependent then processor dependent . :cool: Vikas Amin Embin Technology Bombay vikas.amin@embin.com
vikas amin wrote:
Probably i would preffer to say implementation dependent then processor dependent .
yes but the implementation is dependent on the processor. :)
-Prakash
-
actually, it is not OS dependent, but implementation dependent. standard states that sizeof(int) >= sizeof(short), and short is at least 16 bits. so, for different compilers, sizeof(int) can be different even on the same OS.
Zdeslav Vojkovic wrote:
...sizeof(int) can be different even on the same OS.
Do you have a valid example of such? I've never seen an
int
that varied in size on the same machine.
"Take only what you need and leave the land as you found it." - Native American Proverb
-
Zdeslav Vojkovic wrote:
...sizeof(int) can be different even on the same OS.
Do you have a valid example of such? I've never seen an
int
that varied in size on the same machine.
"Take only what you need and leave the land as you found it." - Native American Proverb
This goes back a bit in time, but... In Microsoft C 6.0 (MS-DOS era), an
int
was 16 bits. Watcom C 9.0, on the same machine, made anint
to be 32 bits. The Microsoft target in this case was 16-bit real-mode MS-DOS while the Watcom target was 32-bit protected mode MS-DOS.
Software Zen:
delete this; // [Fold With Us!](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx)[[^](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx "New Window")]
-
This goes back a bit in time, but... In Microsoft C 6.0 (MS-DOS era), an
int
was 16 bits. Watcom C 9.0, on the same machine, made anint
to be 32 bits. The Microsoft target in this case was 16-bit real-mode MS-DOS while the Watcom target was 32-bit protected mode MS-DOS.
Software Zen:
delete this; // [Fold With Us!](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx)[[^](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx "New Window")]
But was it a true 32-bit
int
? That's like saying we have a 64-bitint
today, but only because Microsoft's compiler mashes two 32-bitint
s together, simulating a bigger one.
"Take only what you need and leave the land as you found it." - Native American Proverb
-
But was it a true 32-bit
int
? That's like saying we have a 64-bitint
today, but only because Microsoft's compiler mashes two 32-bitint
s together, simulating a bigger one.
"Take only what you need and leave the land as you found it." - Native American Proverb
Actually it was. The 80386 processors and their descendents included direct 32-bit arithmetic and pointer support. The Watcom compiler supported protected mode execution with a flat memory model for a variety of DOS extenders. A "DOS extender" basically provided an execution environment for a protected mode application in the MS-DOS environment.
DavidCrow wrote:
Microsoft's compiler mashes two 32-bit ints together
Hmm. Is that still the case? I was under the impression that
__int64
support since VS.NET 2002 was provided directly by native instructions.
Software Zen:
delete this; // [Fold With Us!](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx)[[^](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx "New Window")]
-
Actually it was. The 80386 processors and their descendents included direct 32-bit arithmetic and pointer support. The Watcom compiler supported protected mode execution with a flat memory model for a variety of DOS extenders. A "DOS extender" basically provided an execution environment for a protected mode application in the MS-DOS environment.
DavidCrow wrote:
Microsoft's compiler mashes two 32-bit ints together
Hmm. Is that still the case? I was under the impression that
__int64
support since VS.NET 2002 was provided directly by native instructions.
Software Zen:
delete this; // [Fold With Us!](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx)[[^](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx "New Window")]
Gary R. Wheeler wrote:
Is that still the case?
I'm not sure since I only use VC++ v6.
Gary R. Wheeler wrote:
I was under the impression that __int64 support since VS.NET 2002 was provided directly by native instructions.
Even on processors that do not a have 64-bit bus?
"Take only what you need and leave the land as you found it." - Native American Proverb
-
vikas amin wrote:
Probably i would preffer to say implementation dependent then processor dependent .
yes but the implementation is dependent on the processor. :)
-Prakash
The most important thing to do is to always use the "sizeof" operation in any code you're referring to. Never, ever hardcode the size into your code. When reading/writing to a file - there are exceptions -- in general, avoid using "int" as a type when it comes to storage of data structures. Instead, define types such as DWORD, WORD, BYTE, etc. This will save you a lot of trouble down the road. Read more of what I have to say at http://directx9.blogspot.com/
-
The most important thing to do is to always use the "sizeof" operation in any code you're referring to. Never, ever hardcode the size into your code. When reading/writing to a file - there are exceptions -- in general, avoid using "int" as a type when it comes to storage of data structures. Instead, define types such as DWORD, WORD, BYTE, etc. This will save you a lot of trouble down the road. Read more of what I have to say at http://directx9.blogspot.com/
segment_fault wrote:
The most important thing to do is to always use the "sizeof" operation in any code you're referring to. Never, ever hardcode the size into your code. When reading/writing to a file - there are exceptions -- in general, avoid using "int" as a type when it comes to storage of data structures. Instead, define types such as DWORD, WORD, BYTE, etc. This will save you a lot of trouble down the road.
yes i know that.
-Prakash