Re: [Dev-C++] RES: int and long int sizes
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Michael D. S. <for...@hi...> - 2003-09-01 06:53:43
|
You will notice that everything below is qualified with "probably" or "I=20
believe." An electrical engineer I Am Not, but...
Probably not. Much of this, "save a byte" architecture originated when=20
computers had thousands rather than millions, and now billions of memory=20
positions. I believe it had to do with the fact that the math processor=20
required that numbers be aligned on "word" (4 byte) or "double word" (8=20
byte) boundaries.
For instance, if you had an "a" in memory (position 1) and then a number,=20
if the number was a word boundary, it started in position 4, double word=20
boundary position 8, resulting in 3 in the first case and 7 in the second=20
case skipped (wasted) memory positions. With only a few thousand memory=20
positions thinking about this and packing things in so that as little=20
memory as possible was unused was important.
At least, I think a word was 4 and double word was 8 -- maybe even half=20
word math could be done in assembler -- it's been 35 years and I'm getting=
=20
Alzheimers -- lighten up :)
With 32 bit architecture, everything is aligned on a word boundary and XP=20
is probably 64 bit (double word) architecture. That means that saving=20
(attempting to save) a byte in memory by specifically programming a number=
=20
you know is going to be very small, differently than one you know is going=
=20
to be larger has no meaning any more. Unless of course you have a really=20
large number and you need to specify something like a double double word.
But, at each point in time backwards compatibility was needed so that all=20
the programs that were already written didn't have to be rewritten -- that=
=20
would never be a "feature" for anything new -- so we're still stuck with=20
some of these "ancient" (in computer terms, you know) concepts.
Or something like that -- or maybe you did that wrong :)
ms
At 10:14 PM 8/31/03, you wrote:
>I forgot to tell: Windows XP platform
>
>-----Mensagem original-----
>De: Andr=E9 Mac=E1rio Barros [mailto:and...@su...]
>Enviada em: segunda-feira, 1 de setembro de 2003 00:13
>Para: Dev-Cpp-Users
>Assunto: int and long int sizes
>
>
>Dear Users,
>
> printf("%d\n", sizeof(long int));
>and
> printf("%d\n", sizeof(int));
>
>produces the same value, 4.
>
>Is there no more difference between a int and a long int?
>
>Regards
>Andre Barros
>
>
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by:ThinkGeek
>Welcome to geek heaven.
>http://thinkgeek.com/sf
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|