Paul Herring wrote:
> On 11 Apr 2007 07:13:40 -0700, Knowledge Seeker <[EMAIL PROTECTED]>
> wrote:
>   
>> sizeof int is platform dependent and varies from platform to platform.
>> while sizeof long is always 32-bit
>>     
>
>
> Erm no. 
u r right .. got to brush up knowledge :)


>  An int must, implicitly, be at least 16 bits and a long must be at
> least 32 bits. In addition a long must be at least as long(!) as an int (i.e.
> an int may be shorter, but cannot be longer, than a long.)
>
> It would be quite valid for both to be 36 bits long on a platform.
>
> To the OP, this means that a signed int must hold any number from -32767 to
> 32767 (unsigned should hold 0-65535,) but may extend these limits. A signed
> long must hold a number from -2147483647 to 2147483647 (unsigned should hold
> 0-4294967295; but again, on a platform it may extend this.)
>
> If the data you're handling will fit in the +/-32767 | 0-65535 range, use an
> int, otherwise use a long. That is the only criteria you need concern
> yourself with when choosing which to use.
>
> A platform is not specifically an OS, it is the 'host' environment. A
>   
>> 32-bit OS, with an old C compiler may carry int to be of size 16.
>>
>> Now you can figure out what to use where.
>>
>>
>> Depends on the scenario where to use what ... if you need yashpal_ait21
>> wrote:
>>     
>>> Hi C-programmers,
>>>       Can you please clarify this doubt to me related with 'int'
>>> and 'long' data type in C++? When should a programmer use 'int' and
>>> when should he use 'long'? What is the need of datatype 'long',
>>> when 'int' & 'long' are both 32-bit quantities on a 32-bit OS ?
>>>
>>> Regards,
>>> Yashpal
>>>
>>>
>>>
>>>       
>>
>> To unsubscribe, send a blank message to <mailto:
>> [EMAIL PROTECTED]>.
>> Yahoo! Groups Links
>>
>>
>>
>>
>>     
>
>
>   

Reply via email to