|FROM ||Ruben Safir
|SUBJECT ||Subject: [NYLXS - HANGOUT] C++ Workshop - Introduction
On Tuesday 02 February 2010 03:15:12 Ruben Safir wrote:
> Conceptial Ideas:
> An integer in the C family on the 32 bit Intel clone architecture is
> defined as a marked space in memory of 32 bits in size to represent both
> positive and negitive numbers. On the new 64 bit architecture that many
> of you might have, I don't know if this still holds true since the word
> size of a those machines is 64 bits or 8 bytes
> when you use the declaration
> int a = 3456;
> The computer your program sets aside 32 bits, 4 bytes, of space in ram
> and puts the binary representation of that value in that space.
Unfortunately the size of an 'int' in C/C++ is architecture-specific. You can
only count on an int having _16 bits_ because of that, otherwise the code will
not be portable to architectures that implement an int using only 2 bytes.
This also means that the only numbers that can be guaranteed on all
architectures to be contained within a standard 'int' type is the range -32768
It is for this reason that there are more specific types defined in libraries
in order to be able to specify a particular size of integer. If you have a
look within stdint.h, you'll see int8_t, int16_t, int32_t, int64_t, etc -- and
the underlying types used to create these should differ in implementation with
architecture in order to maintain the expected size. Qt also implements
similar types for the same reason, such as 'qint16'; I honestly don't know if
there's an advantage to using these over the stdint.h from libc6-dev -- it
might have been done more to get around library or declaration dependencies on
different architectures (like __int64 on Windows).
Hire expert Linux talent by posting jobs here :: http://jobs.nylug.org
The nylug-talk mailing list is at nylug-talk-at-nylug.org
The list archive is at http://nylug.org/pipermail/nylug-talk
To subscribe or unsubscribe: http://nylug.org/mailman/listinfo/nylug-talk
----- End forwarded message -----
http://www.mrbrklyn.com - Interesting Stuff
http://www.nylxs.com - Leadership Development in Free Software
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998
http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
"Yeah - I write Free Software...so SUE ME"
"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."
"> I'm an engineer. I choose the best tool for the job, politics be damned.<
You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."
? Copyright for the Digital Millennium