Std's 6.3- conversion- term rank

D

dam_fool_2003

Just now I asked a question about signed char and unsigned char. I had the
replay very fast by jens.torring and Tim prince. I post via google so now
goes my thanking replay. (I must be more precise according to jens.torring's
replay)

As I was reading the slandered draft C99 about the conversion (6.3)
I have interpreted the word conversion rank as the range of a variable
(as per defined in limits.h). Am I wrong in my understanding?

(I went through FAQ and I don't find the correct spot)
 
J

Jack Klein

Just now I asked a question about signed char and unsigned char. I had the
replay very fast by jens.torring and Tim prince. I post via google so now
goes my thanking replay. (I must be more precise according to jens.torring's
replay)

As I was reading the slandered draft C99 about the conversion (6.3)
^^^^^^^^^

Slandered?
I have interpreted the word conversion rank as the range of a variable
(as per defined in limits.h). Am I wrong in my understanding?

(I went through FAQ and I don't find the correct spot)

No, the conversion rank has nothing at all to do with the range of a
type.

It specifically says this in the actual standard:

"The rank of 'long long int' shall be greater than the rank of 'long
int', which shall be greater than the rank of 'int', which shall be
greater than the rank of 'short int', which shall be greater than the
rank of 'signed char'."

It cannot be by range of values, because it is quite common for two or
more different integer types to have the same bit-width and value
range on many implementations.

On 16-bit implementations, short and int usually have the same range.

On today's common 32-bit desk-top systems, int and long usually have
the same range.
 
P

Peter Nilsson

Jack Klein said:
No, the conversion rank has nothing at all to do with the range of a
type.

Nothing at all?!
It specifically says this in the actual standard:

"The rank of 'long long int' shall be greater than the rank of 'long
int', which shall be greater than the rank of 'int', which shall be
greater than the rank of 'short int', which shall be greater than the
rank of 'signed char'."

The sentence before that is...

- The rank of a signed integer type shall be greater than the rank
of any signed integer type with less precision.

Later, 6.2.5p8 says...

For any two integer types with the same signedness and different
integer conversion rank (see 6.3.1.1), the range of values of the
type with smaller integer conversion rank is a subrange of the
values of the other type.

The concepts of range and rank are inextricably linked.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top