Page 1 of 1
					
				long int vs int
				Posted: Tue Apr 16, 2013 11:15 am
				by SukhdeepMankoo
				hi, 
     I searched lot of times in Google, not able to find significant difference between long int and int. As both has same size. How can I know at what time which should I use.
[ Post made via Mobile Device ] 
 
			 
			
					
				Re: long int vs int
				Posted: Tue Apr 16, 2013 4:26 pm
				by Herath
				According to 
this "int" type should have at least 16bit width while "long" type-modified fundamental type has a minimum of 32bit width. Since most of the todays systems are 32bit systems, int and long int should mean the same. The type modifier "long" might not have an effect against the already-32bit "int" type.
 
			 
			
					
				Re: long int vs int
				Posted: Tue Apr 16, 2013 4:40 pm
				by SukhdeepMankoo
				why they declare long int. if they are same.
[ Post made via Mobile Device ] 
 
			 
			
					
				Re: long int vs int
				Posted: Tue Apr 16, 2013 5:05 pm
				by Herath
				Suppose that your program is being compiled with a compiler that compiles the 
int as a 16bit wide data type. If you still need a 32bit wide data type for storing some large value, it is required to use the 
long type modifier before 
int inorder to make it 32bit wide when compiling with a 16bit compiler. And that is what I have in my mind. 

 . 
What i have meant by a 16bit compiler is a compiler that compiles the source code for a 16bit processor.
 
			 
			
					
				Re: long int vs int
				Posted: Wed Apr 17, 2013 6:44 am
				by SukhdeepMankoo
				thanks,
             what about long long int and long int
[ Post made via Mobile Device ] 
 
			 
			
					
				Re: long int vs int
				Posted: Wed Apr 17, 2013 8:34 am
				by Herath
				long - target type will have width of at least 32 bits. 
long long - target type will have width of at least 64 bits (since C++11) 
Copied from : 
http://en.cppreference.com/w/cpp/language/types 
			 
			
					
				Re: long int vs int
				Posted: Fri Apr 19, 2013 10:06 am
				by SukhdeepMankoo
				Thanks
[ Post made via Mobile Device ] 
 
			 
			
					
				Re: long int vs int
				Posted: Mon Jun 24, 2013 4:51 pm
				by evangilbort
				Int is the default type integer that supported by your compiler and it's typically compatible with your hardware and operating system. Integer data types may be different size and it not be allowed to contain negative values. It is commonly represented in a computer as a binary groups of digits.