Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualCornstalks

Posted 02 March 2013 - 01:56 AM

No (there aren't 32-bit systems with a larger int). To get 2 you need 2³¹, but the maximum you can store on a signed 32-bit int is 2³¹-1

It's possible for int to be more than 32-bits on some particular system (even a 32-bit system). It's a rare occurrence (if it ever occurs, hence you'd need to be "lucky"), but not forbidden by C or C++.
 


>In C and C++ you do have minimums. char is at least 8 bits, short and int are at least 16 bits, long is at least 32 and long long is at least 64.

I think char is required to be 8-bit now (although it wasn't the case in old standards, in fact GCC had a platform with a 16-bit char).


Nope. It's required to be at least 8 bits in C++11 and C11. It can be more than 8 bits. The C++ standard builds on the C standard and requires compliance with the following portion of the C standard (among other portions):
 

5.2.4.2.1 Sizes of integer types <limits.h>
 
1 The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. [...] Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.
 
number of bits for smallest object that is not a bit-field (byte)
CHAR_BIT 8

 
It says there that CHAR_BIT, which defines the number of bits in a char, is at least 8 (but may be more: "their implementation-defined values shall be equal or greater...").

#8Cornstalks

Posted 02 March 2013 - 01:46 AM

No (there aren't 32-bit systems with a larger int). To get 2 you need 2³¹, but the maximum you can store on a signed 32-bit int is 2³¹-1

It's possible for int to be more than 32-bits on some particular system (even a 32-bit system). It's a rare occurrence, but not forbidden by C or C++.
 


>In C and C++ you do have minimums. char is at least 8 bits, short and int are at least 16 bits, long is at least 32 and long long is at least 64.

I think char is required to be 8-bit now (although it wasn't the case in old standards, in fact GCC had a platform with a 16-bit char).


Nope. It's required to be at least 8 bits in C++11 and C11. It can be more than 8 bits. The C++ standard builds on the C standard and requires compliance with the following portion of the C standard (among other portions):
 

5.2.4.2.1 Sizes of integer types <limits.h>
 
1 The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. [...] Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.
 
number of bits for smallest object that is not a bit-field (byte)
CHAR_BIT 8

 
It says there that CHAR_BIT, which defines the number of bits in a char, is at least 8 (but may be more: "their implementation-defined values shall be equal or greater...").

#7Cornstalks

Posted 02 March 2013 - 01:46 AM



I'm not sure what's worse here. The fact that "gb" can only take two different values (zero or one) on 32-bit systems

Actually it could be 2 if you're lucky tongue.png


No (there aren't 32-bit systems with a larger int). To get 2 you need 2³¹, but the maximum you can store on a signed 32-bit int is 2³¹-1


It's possible for int to be more than 32-bits on some particular system (even a 32-bit system). It's a rare occurrence, but not forbidden by C or C++.
 


>In C and C++ you do have minimums. char is at least 8 bits, short and int are at least 16 bits, long is at least 32 and long long is at least 64.

I think char is required to be 8-bit now (although it wasn't the case in old standards, in fact GCC had a platform with a 16-bit char).


Nope. It's required to be at least 8 bits in C++11 and C11. It can be more than 8 bits. The C++ standard builds on the C standard and requires compliance with the following portion of the C standard (among other portions):
 

5.2.4.2.1 Sizes of integer types <limits.h>
 
1 The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. [...] Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.
 
number of bits for smallest object that is not a bit-field (byte)
CHAR_BIT 8

 
It says there that CHAR_BIT, which defines the number of bits in a char, is at least 8 (but may be more: "their implementation-defined values shall be equal or greater...").

#6Cornstalks

Posted 02 March 2013 - 01:45 AM



I'm not sure what's worse here. The fact that "gb" can only take two different values (zero or one) on 32-bit systems

Actually it could be 2 if you're lucky tongue.png


No (there aren't 32-bit systems with a larger int). To get 2 you need 2³¹, but the maximum you can store on a signed 32-bit int is 2³¹-1.


It's possible for int to be more than 32-bits on some particular system (even a 32-bit system). It's a rare occurrence, but not forbidden by C or C++.


>In C and C++ you do have minimums. char is at least 8 bits, short and int are at least 16 bits, long is at least 32 and long long is at least 64.

I think char is required to be 8-bit now (although it wasn't the case in old standards, in fact GCC had a platform with a 16-bit char).


Nope. It's required to be at least 8 bits in C++11 and C11. It can be more than 8 bits. The C++ standard builds on the C standard and requires compliance with the following portion of the C standard (among other portions):
 

5.2.4.2.1 Sizes of integer types <limits.h>
 
1 The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. [...] Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.
 
number of bits for smallest object that is not a bit-field (byte)
CHAR_BIT 8

 
It says there that CHAR_BIT, which defines the number of bits in a char, is at least 8 (but may be more: "their implementation-defined values shall be equal or greater...").

#5Cornstalks

Posted 02 March 2013 - 01:44 AM



I'm not sure what's worse here. The fact that "gb" can only take two different values (zero or one) on 32-bit systems

Actually it could be 2 if you're lucky tongue.png


No (there aren't 32-bit systems with a larger int). To get 2 you need 2³¹, but the maximum you can store on a signed 32-bit int is 2³¹-1.


It's possible for int to be more than 32-bits on some particular system (even a 32-bit system). It's a rare occurrence, but not forbidden by C or C++.


>In C and C++ you do have minimums. char is at least 8 bits, short and int are at least 16 bits, long is at least 32 and long long is at least 64.

I think char is required to be 8-bit now (although it wasn't the case in old standards, in fact GCC had a platform with a 16-bit char).


Nope. It's required to be at least 8 bits in C++11 and C11. It can be more than 8 bits. The C++ standard builds on the C standard and requires compliance with the following portion of the C standard (among other portions):
 

5.2.4.2.1 Sizes of integer types <limits.h>
 
1 The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. [...] Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.
 
number of bits for smallest object that is not a bit-field (byte)
CHAR_BIT 8

 
It says there that CHAR_BIT, which defines the number of bits in a char, is at least 8 (but may be more: "their implementation-defined values shall be equal or greater...").

#4Cornstalks

Posted 02 March 2013 - 01:42 AM


>In C and C++ you do have minimums. char is at least 8 bits, short and int are at least 16 bits, long is at least 32 and long long is at least 64.

I think char is required to be 8-bit now (although it wasn't the case in old standards, in fact GCC had a platform with a 16-bit char).


Nope. It's required to be at least 8 bits in C++11 and C11. It can be more than 8 bits. The C++ standard builds on the C standard and requires compliance with the following portion of the C standard (among other portions):
 

5.2.4.2.1 Sizes of integer types <limits.h>
 
1 The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. [...] Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.
 
number of bits for smallest object that is not a bit-field (byte)
CHAR_BIT 8

 
It says there that CHAR_BIT, which defines the number of bits in a char, is at least 8 (but may be more: "their implementation-defined values shall be equal or greater...").

PARTNERS