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 ]
long int vs int
-
- Lieutenant
- Posts: 92
- Joined: Tue Oct 27, 2009 7:50 pm
Re: long int vs int
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.
-
- Lieutenant
- Posts: 92
- Joined: Tue Oct 27, 2009 7:50 pm
Re: long int vs int
why they declare long int. if they are same.
[ Post made via Mobile Device ]
[ Post made via Mobile Device ]
Re: long int vs int
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.
What i have meant by a 16bit compiler is a compiler that compiles the source code for a 16bit processor.
-
- Lieutenant
- Posts: 92
- Joined: Tue Oct 27, 2009 7:50 pm
Re: long int vs int
thanks,
what about long long int and long int
[ Post made via Mobile Device ]
what about long long int and long int
[ Post made via Mobile Device ]
Re: long int vs int
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
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
-
- Lieutenant
- Posts: 92
- Joined: Tue Oct 27, 2009 7:50 pm
Re: long int vs int
Thanks
[ Post made via Mobile Device ]
[ Post made via Mobile Device ]
-
- Sergeant
- Posts: 12
- Joined: Fri Jun 21, 2013 12:19 pm
Re: long int vs int
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.