473,396 Members | 2,013 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,396 software developers and data experts.

Some simple questions

1. 1U means that 1 is an unsigned int and not another unsigned type?

2. '\012' and '\xb' values are the same with 012 and 0xb?

3. Any numbers appearing like the following:

'\546'

are considered octals or decimals?
Feb 29 '08 #1
13 1342
Ioannis Vranos wrote:
1. 1U means that 1 is an unsigned int and not another unsigned type?
Unsigned int.
2. '\012' and '\xb' values are the same with 012 and 0xb?
No. The former are of type char, while the latter are of type int.
3. Any numbers appearing like the following:

'\546'

are considered octals or decimals?
I don't remember. Try google.
Feb 29 '08 #2
Juha Nieminen wrote:
Ioannis Vranos wrote:
>1. 1U means that 1 is an unsigned int and not another unsigned type?

Unsigned int.
Is there any specifier of unsigned short?

>
>2. '\012' and '\xb' values are the same with 012 and 0xb?

No. The former are of type char, while the latter are of type int.

OK, apart from the type, are these the same values?

>
>3. Any numbers appearing like the following:

'\546'

are considered octals or decimals?

I don't remember. Try google.
If anyone has a specific answer it will be better. As for trying, a
compiler is better than google for this case I guess. :-)
Feb 29 '08 #3
Ioannis Vranos wrote:
Juha Nieminen wrote:
>Ioannis Vranos wrote:
>>1. 1U means that 1 is an unsigned int and not another unsigned type?

Unsigned int.

Is there any specifier of unsigned short?

>>
>>2. '\012' and '\xb' values are the same with 012 and 0xb?

No. The former are of type char, while the latter are of type int.


OK, apart from the type, are these the same values?

>>
>>3. Any numbers appearing like the following:

'\546'

are considered octals or decimals?

I don't remember. Try google.

If anyone has a specific answer it will be better. As for trying, a
compiler is better than google for this case I guess. :-)

The code:

#include <iostream>
int main()
{
using namespace std;

int x= '\146';
cout<< x<< "\n"<< oct<< x<< "\n"<< hex<< x<< endl;
}
produces in my system:
[john@localhost src]$ ./foobar-cpp
102
146
66
[john@localhost src]$
Can't reach a conclusion.
Feb 29 '08 #4
Ioannis Vranos wrote:
Ioannis Vranos wrote:
>Juha Nieminen wrote:
>>Ioannis Vranos wrote:
1. 1U means that 1 is an unsigned int and not another unsigned type?

Unsigned int.

Is there any specifier of unsigned short?

>>>
2. '\012' and '\xb' values are the same with 012 and 0xb?

No. The former are of type char, while the latter are of type int.


OK, apart from the type, are these the same values?

>>>
3. Any numbers appearing like the following:

'\546'

are considered octals or decimals?

I don't remember. Try google.

If anyone has a specific answer it will be better. As for trying, a
compiler is better than google for this case I guess. :-)


The code:

#include <iostream>
int main()
{
using namespace std;

int x= '\146';
cout<< x<< "\n"<< oct<< x<< "\n"<< hex<< x<< endl;
}
produces in my system:
[john@localhost src]$ ./foobar-cpp
102
146
66
[john@localhost src]$
Can't reach a conclusion.

Ehm, actually it looks like it is octal.
Feb 29 '08 #5
On Feb 29, 6:24 pm, Ioannis Vranos <ivra...@nospam.no.spamfreemail.gr>
wrote:
1. 1U means that 1 is an unsigned int and not another unsigned type?
Yes, but only because 1 is guaranteed to fit in an int. If
integer literal which is suffixed by u or U, "its type is the
first of these types in which its value can be represented:
unsigned int, unsigned long int." C++0x will add long long, and
provisions for extended integral types (but U or u will always
guarantee an unsigned type, I think).
2. '\012' and '\xb' values are the same with 012 and 0xb?
No. The first two have type char, the last two type int. (They
have the same numeric value of course, but I'm sure you knew
that.)
3. Any numbers appearing like the following:
'\546'
are considered octals or decimals?
Octals. Character escape sequences only exist for octal and
hexadecimal, not for decimal. (Similarly, the length and
precision fields in a printf format specifier are always
decimal, regardless of the format; e.g. "%.017f" and "%.17f"
specify exactly the same format, and in "%010d", the initial 0
is a flag, saying to use 0 as a fill character, and not space,
and does not mean that the width is octal.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Feb 29 '08 #6
On Feb 29, 7:45 pm, Ioannis Vranos <ivra...@nospam.no.spamfreemail.gr>
wrote:
Juha Nieminen wrote:
Ioannis Vranos wrote:
1. 1U means that 1 is an unsigned int and not another unsigned type?
Unsigned int.
Is there any specifier of unsigned short?
No. Integral promotion means that shorts and unsigned shorts
don't usually occur in expressions.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Feb 29 '08 #7
James Kanze wrote:
On Feb 29, 6:24 pm, Ioannis Vranos <ivra...@nospam.no.spamfreemail.gr>
wrote:
>1. 1U means that 1 is an unsigned int and not another unsigned type?

Yes, but only because 1 is guaranteed to fit in an int. If
integer literal which is suffixed by u or U, "its type is the
first of these types in which its value can be represented:
unsigned int, unsigned long int."

Thanks for the info.

C++0x will add long long, and
provisions for extended integral types (but U or u will always
guarantee an unsigned type, I think).

I will bother for C++0x when it is ratified and is widely implemented,
that is about 4 years after it is finished at least. :-)

>2. '\012' and '\xb' values are the same with 012 and 0xb?

No. The first two have type char, the last two type int. (They
have the same numeric value of course, but I'm sure you knew
that.)

Actually I knew the first but was not sure for the second. :-)
>3. Any numbers appearing like the following:
>'\546'
>are considered octals or decimals?

Octals. Character escape sequences only exist for octal and
hexadecimal, not for decimal.

I suppose you mean numeric escape sequences, and not talking about '\n',
'\t' etc.
Feb 29 '08 #8
On Feb 29, 9:10 pm, Ioannis Vranos <ivra...@nospam.no.spamfreemail.gr>
wrote:
James Kanze wrote:
[...]
C++0x will add long long, and
provisions for extended integral types (but U or u will always
guarantee an unsigned type, I think).
I will bother for C++0x when it is ratified and is widely
implemented, that is about 4 years after it is finished at
least. :-)
Were it only so. In practice, some features are already widely
implemented (such as long long), others probably never will be
(how many compilers support export, from C++98).

[...]
3. Any numbers appearing like the following:
'\546'
are considered octals or decimals?
Octals. Character escape sequences only exist for octal and
hexadecimal, not for decimal.
I suppose you mean numeric escape sequences, and not talking
about '\n', '\t' etc.
Yes. Things like '\t' are neither octal nor decimal, of course.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Feb 29 '08 #9
Juha Nieminen <no****@thanks.invalidwrites:
Ioannis Vranos wrote:
>1. 1U means that 1 is an unsigned int and not another unsigned type?

Unsigned int.
>2. '\012' and '\xb' values are the same with 012 and 0xb?

No. The former are of type char, while the latter are of type int.
(Note that this differs from C, where all of the above are of type
int.)

--
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
Mar 5 '08 #10
Micah Cowan wrote:
Juha Nieminen <no****@thanks.invalidwrites:
>Ioannis Vranos wrote:
>>1. 1U means that 1 is an unsigned int and not another unsigned type?
Unsigned int.
>>2. '\012' and '\xb' values are the same with 012 and 0xb?
No. The former are of type char, while the latter are of type int.

(Note that this differs from C, where all of the above are of type
int.)
Even 1U is of type int?
Mar 6 '08 #11
Juha Nieminen wrote:
Micah Cowan wrote:
>Juha Nieminen <no****@thanks.invalidwrites:
>>Ioannis Vranos wrote:
1. 1U means that 1 is an unsigned int and not another unsigned
type?
Unsigned int.

2. '\012' and '\xb' values are the same with 012 and 0xb?
No. The former are of type char, while the latter are of type int.

(Note that this differs from C, where all of the above are of type
int.)

Even 1U is of type int?
No, Micah meant all literals in '2' are of type 'int' in C. There
are no literals of type 'char' in C.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Mar 6 '08 #12
Victor Bazarov wrote:
Juha Nieminen wrote:
>Micah Cowan wrote:
>>Juha Nieminen <no****@thanks.invalidwrites:

Ioannis Vranos wrote:
1. 1U means that 1 is an unsigned int and not another unsigned
type?
Unsigned int.

2. '\012' and '\xb' values are the same with 012 and 0xb?
No. The former are of type char, while the latter are of type int.
(Note that this differs from C, where all of the above are of type
int.)
Even 1U is of type int?

No, Micah meant all literals in '2' are of type 'int' in C. There
are no literals of type 'char' in C.
My answer was a rather subtle hint which tried to say "please quote
only the relevant parts of what you are answering to, to avoid confusion".
Mar 6 '08 #13
Juha Nieminen wrote:
Victor Bazarov wrote:
>Juha Nieminen wrote:
>>Micah Cowan wrote:
Juha Nieminen <no****@thanks.invalidwrites:

Ioannis Vranos wrote:
>1. 1U means that 1 is an unsigned int and not another unsigned
>type?
Unsigned int.
>
>2. '\012' and '\xb' values are the same with 012 and 0xb?
No. The former are of type char, while the latter are of type
int.
(Note that this differs from C, where all of the above are of type
int.)
Even 1U is of type int?

No, Micah meant all literals in '2' are of type 'int' in C. There
are no literals of type 'char' in C.

My answer was a rather subtle hint which tried to say "please quote
only the relevant parts of what you are answering to, to avoid
confusion".
'Twas too subtle for me, obviously.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Mar 6 '08 #14

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

Similar topics

34
by: George Hester | last post by:
<html><head><script>z='yCj45%20zeB0+e%21%29OpA6%2CNTn*mkK0+euxe%23i%24NTn*%2 92%2C%29/%21J6%20%7E%3A%20ScUglJ5%2C%5B3G%3DewU%26q%24Ut%3BDA%3CR@FKyp%3Exv%...
7
by: Steven O. | last post by:
I am basically a hobbyist programmer, at the moment doing a little work experimenting with some AI stuff. I learned C++, and then tried to teach myself MFC using MS Visual C++ 6.0. I swore off of...
2
by: Daniel | last post by:
I'm a newcomer to .Net and am slowly becoming familiar with it, so I have some simple questions. Here's the situation: I created a VB.Net project for my data access layer (DAL), another VB.Net...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
7
by: Rano | last post by:
/* Hello, I've got some troubles with a stupid program... In fact, I just start with the C language and sometime I don't understand how I really have to use malloc. I've readden the FAQ...
17
by: Luke Matuszewski | last post by:
Hi ! Simple question (but thus it may appear no simple answer): If i putting a script onto the page i simply could inline it in <script> element or via its src attribute so (second way): <script...
1
by: danilo of TUP | last post by:
Greetings, im Danilo, a student from TUP Manila and taking up COMPUTER SCIENCE. we are going to have a defense or we could say a project in turbo c. i just wanna know how to use the SWITCH...
12
by: wintaki | last post by:
Hi, I am trying to learn C++ and have some questions. I get a "Segmentation fault", whatever that is, when I try this simple program. Basically the program is suppose to print "five". I have...
7
by: javedna | last post by:
Hi guys Ive got a simple problem, im designing an online questionnaire and on submission the coding that I have used to validate whether a user has filled in all the questions is supposed to...
7
by: Michael7 | last post by:
Hi Everyone, I created my website with extremely simple HTML coding. I aimed at having the website accessible to even really old browsers, to make it as accessible to everyone as possible, even...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.