The C++ FAQ item 29.5 (this seems to be strongly related to C), at
<url: http://www.parashift.c om/c++-faq-lite/newbie.html#faq-29.5>
mentions that
<quote>
C++ guarantees a char is exactly one byte which is at least 8 bits, short
is at least 16 bits, int is at least 16 bits, and long is at least 32
bits.
</quote>
Questions:
(1) This guarantee seems to come from the C standard. Which I don't
have. Does the C++ standard really guarantee this?
(2) Is this guarantee originally formulated in terms of number of bits,
or in terms of e.g. decimal value ranges?
(3) Concerning (2), if formulated in terms of number of bits, are the number
of bits mentioned simply sizeof(T)*CHAR_ BIT, which doesn't say much about
value ranges, or are they stated to be the value representation bits?
(Intentionally cross-posted [comp.lang.c++] and [comp.lang.c]).
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 14 '05
30 1415
Victor Bazarov wrote: "Andreas Huber" <ah************ ********@yahoo. com> wrote... Alf P. Steinbach wrote: [snip] short is at least 16 bits, int is at least 16 bits, and long is at least 32 bits. </quote> That is contrary to what my copy of the standard says (see 3.9.1/1). It basically says that char <= short <= int <= long (i.e. there is no
I wonder what _exactly_ does your copy say in 3.9.1/1 that makes you derive that 'char <= short <= int'.
I was wrong, it's actually 3.9.1/2...
But that doesn't matter. You are actually correct, the C standard defined those relationships between type sizes. It is true that char <= short <= int. It does not, however, mean that there is no guarantee that 'int' is larger than 'char'. The same C90 Standard when describing <limits.h> (and see 18.2.2/2 to know that C++ mandates the same values for all xx_MAX and xx_MIN values), does require *at least* ranges -32767..32767 for 'int' and -2^31..2^31 for 'long'.
guarantee that a long is any bigger than a char, although there probably is no platform where sizeof(long) == sizeof(char)). For more information see 5.3.3 and 1.7..
For more information see 18.2.2
<blush> Ok, you got me on the left foot there. Although the C++ standard
does not itself guarantee anything like that, it *refers* to C standard
of which I don't even have a copy available... oh well.
Thanks for clarifying.
Regards,
--
Andreas Huber
When replying by private email, please remove the words spam and trap
from the address shown in the header.
"Alf P. Steinbach" wrote: CBFalconer: "Alf P. Steinbach" wrote:
.... snip ... (1) This guarantee seems to come from the C standard. Which I don't have. Does the C++ standard really guarantee this?
I dunno. This is c.l.c. Google for N869 to get the last draft of the C standard. f'ups set, which you should have done in the original posting.
It was intentionally cross-posted; F.U.T. overridden. :-)
You got your inputs from c.l.c, now it should go away. That's why
you should have set fups in the first place, and not have
overridden mine. Notice I didn't object to the initial cross-post.
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Ioannis Vranos wrote: Alf P. Steinbach wrote:
.... snip ... (1) This guarantee seems to come from the C standard. Which I don't have. Does the C++ standard really guarantee this?
Yes. Also, except where otherwise is stated, C90 is a subset of C++98 standard.
See what happens when you don't set followups in the initial
query. Misinformation like this works its way into c.l.c and is
likely to produce an interminable stupid cross group argument.
It's bad enough when the misinformation is native to the group.
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
On Sat, 05 Feb 2005 13:11:04 GMT, al***@start.no (Alf P. Steinbach)
wrote in comp.lang.c: The C++ FAQ item 29.5 (this seems to be strongly related to C), at <url: http://www.parashift.c om/c++-faq-lite/newbie.html#faq-29.5> mentions that
<quote> C++ guarantees a char is exactly one byte which is at least 8 bits, short is at least 16 bits, int is at least 16 bits, and long is at least 32 bits. </quote>
Questions:
(1) This guarantee seems to come from the C standard. Which I don't have. Does the C++ standard really guarantee this?
[snip]
The fact that the C++ standard decided to cite the C standard as a
normative reference is irrelevant here in comp.lang.c. The POSIX
standard is also based on the C standard, but that doesn't make POSIX
topical in comp.lang.c either.
What the C++ language guarantees is 100% off-topic in c.l.c, period.
The fact that the C++ standard does or does not refer to any or all
parts of the C standard has no meaning at all in terms of C.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
* Jack Klein: On Sat, 05 Feb 2005 13:11:04 GMT, al***@start.no (Alf P. Steinbach) wrote in comp.lang.c:
The C++ FAQ item 29.5 (this seems to be strongly related to C), at <url: http://www.parashift.c om/c++-faq-lite/newbie.html#faq-29.5> mentions that
<quote> C++ guarantees a char is exactly one byte which is at least 8 bits, short is at least 16 bits, int is at least 16 bits, and long is at least 32 bits. </quote>
Questions:
(1) This guarantee seems to come from the C standard. Which I don't have. Does the C++ standard really guarantee this?
[snip]
The fact that the C++ standard decided to cite the C standard as a normative reference is irrelevant here in comp.lang.c. The POSIX standard is also based on the C standard, but that doesn't make POSIX topical in comp.lang.c either.
What the C++ language guarantees is 100% off-topic in c.l.c, period. The fact that the C++ standard does or does not refer to any or all parts of the C standard has no meaning at all in terms of C.
You mean, you don't have the slightest clue about the C aspects (although
you could easily check up on that, since you do have that standard), and
therefore choose to answer the 1/3 C++ part -- with some sour grapes.
Have a nice weekend.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
On Sun, 06 Feb 2005 02:16:08 GMT, al***@start.no (Alf P. Steinbach)
wrote in comp.lang.c: * Jack Klein: On Sat, 05 Feb 2005 13:11:04 GMT, al***@start.no (Alf P. Steinbach) wrote in comp.lang.c:
The C++ FAQ item 29.5 (this seems to be strongly related to C), at <url: http://www.parashift.c om/c++-faq-lite/newbie.html#faq-29.5> mentions that
<quote> C++ guarantees a char is exactly one byte which is at least 8 bits, short is at least 16 bits, int is at least 16 bits, and long is at least 32 bits. </quote>
Questions:
(1) This guarantee seems to come from the C standard. Which I don't have. Does the C++ standard really guarantee this?
[snip]
The fact that the C++ standard decided to cite the C standard as a normative reference is irrelevant here in comp.lang.c. The POSIX standard is also based on the C standard, but that doesn't make POSIX topical in comp.lang.c either.
What the C++ language guarantees is 100% off-topic in c.l.c, period. The fact that the C++ standard does or does not refer to any or all parts of the C standard has no meaning at all in terms of C.
You mean, you don't have the slightest clue about the C aspects (although you could easily check up on that, since you do have that standard), and therefore choose to answer the 1/3 C++ part -- with some sour grapes.
Yes, I do, and had you posted this to comp.lang.c++ ONLY, I would have
been happy to answer based on what the C++ standard inherits from the
C standard.
But whether the C++ standard decided to incorporate the C standard in
its entirety, which it does not, or decided to only incorporate the
third comma on page 47, which it also does not, it not a C language
issue or topical for comp.lang.c at all.
There is no mention of the C++ language at all in the (now superceded
version) of the C standard that C++ chose to incorporate.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
..lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
On Sat, 5 Feb 2005 20:30:18 +0000 (UTC), in comp.lang.c , infobahn
<in******@btint ernet.com> wrote: Victor Bazarov wrote: I wonder what _exactly_ does your copy say in 3.9.1/1 that makes you derive that 'char <= short <= int'. But that doesn't matter. You are actually correct, the C standard defined those relationships between type sizes.
C&V please.
5.2.4.2.1 Sizes of Integral types.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >
On Sun, 06 Feb 2005 02:16:08 GMT, in comp.lang.c , al***@start.no (Alf P.
Steinbach) wrote: * Jack Klein: What the C++ language guarantees is 100% off-topic in c.l.c, period. The fact that the C++ standard does or does not refer to any or all parts of the C standard has no meaning at all in terms of C.
You mean, you don't have the slightest clue about the C aspects
Before posting such remarks, you might want to check up on Jack's
credentials, posting history etc. You just made a fool of yourself.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >
Mark McIntyre <ma**********@s pamcop.net> writes: On Sat, 5 Feb 2005 20:30:18 +0000 (UTC), in comp.lang.c , infobahn <in******@btint ernet.com> wrote:
Victor Bazarov wrote: I wonder what _exactly_ does your copy say in 3.9.1/1 that makes you derive that 'char <= short <= int'. But that doesn't matter. You are actually correct, the C standard defined those relationships between type sizes.
C&V please.
5.2.4.2.1 Sizes of Integral types.
Which actually discusses the ranges of integer types, which, in the
presence of padding bits, may not be directly related to their sizes.
A sufficiently perverse implementation could have
sizeof(long) < sizeof(int).
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
* Mark McIntyre: On Sun, 06 Feb 2005 02:16:08 GMT, in comp.lang.c , al***@start.no (Alf P. Steinbach) wrote:
* Jack Klein: What the C++ language guarantees is 100% off-topic in c.l.c, period. The fact that the C++ standard does or does not refer to any or all parts of the C standard has no meaning at all in terms of C. You mean, you don't have the slightest clue about the C aspects
Before posting such remarks, you might want to check up on Jack's credentials, posting history etc.
I know Jack's posting history for several years.
You just made a fool of yourself.
Before posting such remarks, you might want to check up on my
credentials, posting history etc.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ladvánszky Károly |
last post by:
Entering 3.4 in Python yields 3.3999999999999999.
I know it is due to the fact that 3.4 can not be precisely expressed by the
powers of 2. Can the float handling rules of the underlying layers be set
from Python so that 3.4 yield 3.4?
Thanks,
Károly
|
by: Alf P. Steinbach |
last post by:
The C++ FAQ item 29.5 (this seems to be strongly related to C), at
<url: http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.5>
mentions that
<quote>
C++ guarantees a char is exactly one byte which is at least 8 bits, short
is at least 16 bits, int is at least 16 bits, and long is at least 32
bits.
</quote>
|
by: Kyle Kolander |
last post by:
Sorry, I sent this to comp.std.c++ and meant to send it here as well...
Why are the minimum size guarantees for fundamental types intentionally
omitted from section 3.9.1 Fundamental types of the C++ standard? If indeed
these guarantees can be inferred from other parts of the standard, and it is
the intent of the standards committee that these guarantees exist, then why
are they not listed in the most relevant section?
I've been...
|
by: Ben O'Steen |
last post by:
Scenario:
=========
Using PyGame in particular, I am trying to write an application that will
run a scripted timeline of events, eg at 5.5 seconds, play xxx.mp3 and put
the image of a ball on screen, at 7.8 seconds move the ball up and down.
At this point, I hear you say 'Oh, like Flash'.
Yes, well... Like Flash, but I don't want to take this app in the same
direction as Macromedia took Flash, nor do I (ever) want the two to be
|
by: ranjeet.gupta |
last post by:
Dear ALL
As we know that when we declare the union then we have the size of the
union which is the size of the highest data type as in the below case
the
size should be 4 (For my case and compiler), and it is,
what I conclude from the below code
union data_type {
| |
by: subramanian100in |
last post by:
Consider the following program
#include <limits.h>
#include <stddef.h>
int main(void)
{
size_t size;
size_t bytes = sizeof(size_t);
|
by: n3o |
last post by:
Hello Comp.Lang.C Members,
I have an issue with user input that I have been trying to figure out
for the longest. For instance, let's say you have something like this:
void foo()
{
int num;
printf("Please enter a number: ");
scanf("%d", &num); // yes I know this function may throw a
|
by: jehugaleahsa |
last post by:
Hello:
I am experiencing performance related issues when my custom data
structures work with value types. I use generics to prevent boxing
wherever I can. For instance, I use IEqualityComparer, etc. I have
gone through most of my data structures and verified that I don't
compare to null or call methods that would box my value types.
However, I am still experiencing performance problems. I can process
strings faster than I can process...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |