|
From: jansb000 <jan...@wx...> - 2001-10-23 21:00:30
|
Yep, just try this program:
#include <stdio.h>
int main() {
printf("%d", sizeof(int));
}
For a more complete version of this program look at:
http://wcs-jabe.sourceforge.net/source/html/global_8h-source.html
http://wcs-jabe.sourceforge.net/source/html/globmain_8cpp-source.html
This is a program that I wrote to test the size of variables on =
different platforms (C++).
As far as I know an int is always the size that can be handled most =
easily by the CPU but minimal 16 bits. So, on the new Intel processor (I =
believe its the MERCAD) an int may be 64 bits since it is a 64-bit CPU. =
Some super computers also have 64-bit ints.
If you write cross-platform code then you should use 16-bit for integer =
(as an assumption), but you can never count on it that it will occupy =
just 2 bytes of memory.
----- Original Message -----=20
From: Daniel Glenfield=20
To: jan...@wx...=20
Sent: Friday, October 19, 2001 9:06 PM
Subject: Re: [Dev-C++] Unsigned and signed
that's it, knew I had the first 2 numbers right.
so you're telling me that a 32-bit machine can hold even greater =
values for int ? great, that's something my course never told me!
>From: "jansb000"=20
>To: "Daniel Glenfield"=20
>Subject: Re: [Dev-C++] Unsigned and signed=20
>Date: Fri, 19 Oct 2001 21:03:21 +0200=20
>=20
>You mean its -32768 to +32767 for signed and +65535 for unsigned.=20
>However that is only for 16-bit numbers. In DevC++/MingW32 an integer =
is by default 32-bit. On other machines it may be even 64-bit.=20
> ----- Original Message -----=20
> From: Daniel Glenfield=20
> To: dev...@li...=20
> Sent: Friday, October 19, 2001 5:08 PM=20
> Subject: RE: [Dev-C++] Unsigned and signed=20
>=20
>=20
> int holds any number from -32,332 to +32,332 (not sure about last 3 =
digits in each)=20
>=20
> and an unsigned int holds +64, 664 (again not sure about last 3)=20
>=20
>=20
>=20
> >From: "Ioannis Vranos"=20
> >To: "Dev-C++"=20
> >Subject: RE: [Dev-C++] Unsigned and signed=20
> >Date: Fri, 19 Oct 2001 17:54:32 +0200=20
> >=20
> >signed integer variables can store both positive and negative =
variables,=20
> >unsigned only positive.=20
> >=20
> >e.g.=20
> >int x;=20
> >signed int x; // They are both the same=20
> >=20
> >unsigned int x;=20
> >=20
> >long y;=20
> >signed long y; // They are both the same=20
> >=20
> >unsigned long y;=20
> >=20
> >=20
> >In the case of int the "int" can be avoided:=20
> >=20
> >int x;=20
> >signed x; // They are both the same=20
> >=20
> >unsigned x;=20
> >=20
> >=20
> >Also normally we do not use signed but only unsigned when we need =
so:=20
> >=20
> >int x; // signed=20
> >long y; //signed=20
> >=20
> >unsigned z; // unsigned int=20
> >unsigned long y;=20
> >unsigned char c;=20
> >=20
> >But a char it can be signed or unsigned. It depends from the =
system.=20
> >=20
> >E.g. char c; // it can be signed or unsigned=20
> >=20
> >signed char c; // signed=20
> >unsigned char c; // unsigned=20
> >=20
> >=20
> >Ioannis=20
> >=20
> >* Ioannis Vranos=20
> >* Programming pages: http://www.noicys.f2s.com=20
> >* Alternative URL: http://run.to/noicys=20
> >=20
> >=20
> >=20
> >=20
> > > -----Original Message-----=20
> > > From: dev...@li...=20
> > > [mailto:dev...@li...] On Behalf=20
> > > Of mi...@ju...=20
> > > Sent: Friday, October 19, 2001 1:36 PM=20
> > > To: dev...@li...=20
> > > Subject: [Dev-C++] Unsigned and signed=20
> > >=20
> > >=20
> > > What do unsigned and signed do to variables?=20
> > > ________________________________________________________________ =
> > > GET INTERNET ACCESS FROM JUNO!=20
> > > Juno offers FREE or PREMIUM Internet access for less!=20
> > > Join Juno today! For your FREE software, visit:=20
> > > http://dl.www.juno.com/get/web/.=20
> > >=20
> > >=20
> > > _______________________________________________=20
> > > Dev-cpp-users mailing list=20
> > > Dev...@li...=20
> > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users=20
> > >=20
> >=20
> >=20
> >_______________________________________________=20
> >Dev-cpp-users mailing list=20
> >Dev...@li...=20
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users=20
>=20
>=20
=
>------------------------------------------------------------------------=
------=20
> Get your FREE download of MSN Explorer at http://explorer.msn.com=20
> _______________________________________________ Dev-cpp-users =
mailing list Dev...@li... =
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users=20
-------------------------------------------------------------------------=
-----
Get your FREE download of MSN Explorer at http://explorer.msn.com
|