473,378 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

rank and expressions

what's the rules of rank and how they affect types of expressions?
Nov 14 '05 #1
3 1317
j0mbolar wrote on 30/07/04 :
what's the rules of rank and how they affect types of expressions?


What are you talking about ? Can you be more specific ?

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"

Nov 14 '05 #2
Emmanuel Delahaye <em***@YOURBRAnoos.fr> wrote in message news:<mn***********************@YOURBRAnoos.fr>...
j0mbolar wrote on 30/07/04 :
what's the rules of rank and how they affect types of expressions?


What are you talking about ? Can you be more specific ?


I thought I was specific enough. rank only exist for one aspect
of C and that is types; like int <= unsigned int <= long
I don't know the rules exactly, which is why I was asking.

There are problems with this model iirc, because
int can be larger than unsigned int, so an expression
involving a variable that's type is unsigned int and a
variable that's type is int, the unsigned int variable
would be promoted to int, right?

and for variables of type unsigned short or unsigned char,
used with constants or variables of type int, get promoted
to type int or they can be promoted to type unsigned int
if int can't represent them. Though I think that would
never be the case as int would probably always be able
to represent unsigned char or unsigned short.

Also, I wonder if the case of short int not being able
to be represented by int could ever arise.
Nov 14 '05 #3
j0mbolar wrote:
Emmanuel Delahaye <em***@YOURBRAnoos.fr> wrote in message news:<mn***********************@YOURBRAnoos.fr>...
j0mbolar wrote on 30/07/04 :
what's the rules of rank and how they affect types of expressions?
What are you talking about ? Can you be more specific ?

I thought I was specific enough. rank only exist for one aspect
of C and that is types; like int <= unsigned int <= long
I don't know the rules exactly, which is why I was asking.

There are problems with this model iirc, because
int can be larger than unsigned int, so an expression
involving a variable that's type is unsigned int and a
variable that's type is int, the unsigned int variable
would be promoted to int, right?


No. All non-negative `int' values can be represented
as `unsigned int' (section 6.2.6.2 paragraph 2).
and for variables of type unsigned short or unsigned char,
used with constants or variables of type int, get promoted
to type int or they can be promoted to type unsigned int
if int can't represent them. Though I think that would
never be the case as int would probably always be able
to represent unsigned char or unsigned short.
Some people have written here about machines on which
`char', `short', and `int' are all 32 bits wide. On such
a machine, `unsigned char' and `unsigned short' can express
values that are too large for `int'.

I haven't personally used such machines, but I have
used systems on which `short' and `int' were both 16 bits
wide. On such systems, an `unsigned short' could hold
values too large for an `int'.
Also, I wonder if the case of short int not being able
to be represented by int could ever arise.


Every `short' value can be represented as an `int'
(section 6.2.5 paragraph 8, plus 6.3.1.1 paragraph 1).
More completely, every `signed char' value can be
represented as a `short', every `short' value can be
represented as an `int', and every `int' value can be
represented as a `long'. This is sometimes shown
informally as

signed char <= short <= int <= long

In C89 it was easy to enumerate all the signed and
unsigned integer types and arrange them in a "pecking
order" like this one. But C99 has a thornier problem
to solve, not because of the introduction of `long long'
and `_Bool' (it'd be easy to insert them in a C89-style
list) but because the C99 Standard permits an implementation
to define new integer types beyond those explicitly named.
Some of these types, if the implementation provides them,
are given special names in <stdint.h> (section 7.18.1). But
now you've got a problem: Does `int_least16_t' promote to
`int', to `unsigned int', or perhaps not at all? Well, it
all depends on the implementation-defined characteristics
of both `int' and `int_least16_t', doesn't it? How is the
Standard to speak sensibly about all the possible variations?

To cope with the problem, C99 introduces the notion of
the "rank" of an integer type. 6.3.1.1 describes how ranks
are determined, and it's really just the `signed char <= short'
chain you're familiar with from C89, with generalizations to
allow other implementation-defined types to be inserted in
the appropriate positions. The "rank" of an integer type is
simply its position in the pecking order, and the concept
permits the Standard to describe promotions and conversions
in a general way without trying to enumerate every possible
integer type every implementation might ever dream up.

--
Er*********@sun.com

Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Can | last post by:
I am creating an on-line survey. I want the user to have a list of choices of say 10 items that are radio buttons. They need to rank their preference. They click on preference 1, that option is...
3
by: bughunter | last post by:
I discover next problem I have view definition with rank() create view vTEST as select c1, c2, c3, ... -- problem area start , rank() over (order by c3) as RNK -- problem area stop from...
3
by: Elden Carnahan | last post by:
I am trying to derive rank values in a query, just as one would with the Rank function in Excel. Can't see how to do this elementary task. Can anyone advise?
2
by: dam_fool_2003 | last post by:
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...
1
by: Joe | last post by:
Has anyone written a percentile rank algorithm that they can share or know of a good resource that defines the algorithm. I'm starting a project that involves percentile ranks, logistic and linear...
13
by: Steve Edwards | last post by:
Hi, Given a map: typedef map<long, string, greater<long> > mapOfFreq; Is there a quicker way to find the rank (i.e. index) of the elememt that has the long value of x? At the moment I'm...
1
by: volunteer | last post by:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="filename.xsl"?> <markers date="20060523"> 04:21:50 PM <marker sn="1" rank="6" name="john" /> <marker sn="2" rank="5"...
2
by: orenlevy1 | last post by:
Hi Everyone. I have a problem that I could not figure out what to do with it. I have a couple of tables and views. All have the same unique ID. When a user try to do a search on our web site...
6
by: canabatz | last post by:
Hello . i got a list of user with ranking . i want to display the first five places where it is not the same user, like that john : is rank 1 john john david : is rank 2 albert : is rank 3...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.