Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #5179 > unrolled thread
| Started by | "crea" <no@invalid.com> |
|---|---|
| First post | 2011-05-19 20:13 +0100 |
| Last post | 2011-05-20 00:39 +0200 |
| Articles | 8 — 5 participants |
Back to article view | Back to comp.lang.c++
'5'-'0' = 5 alway? guaranteed? "crea" <no@invalid.com> - 2011-05-19 20:13 +0100
Re: '5'-'0' = 5 alway? guaranteed? "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-05-19 21:28 +0200
Re: '5'-'0' = 5 alway? guaranteed? "crea" <no@invalid.com> - 2011-05-19 20:35 +0100
Re: '5'-'0' = 5 alway? guaranteed? Noah Roberts <dont@email.me> - 2011-05-19 12:58 -0700
Re: '5'-'0' = 5 alway? guaranteed? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-19 16:10 -0400
Re: '5'-'0' = 5 alway? guaranteed? Pete Becker <pete@versatilecoding.com> - 2011-05-19 16:21 -0400
Re: '5'-'0' = 5 alway? guaranteed? "crea" <no@invalid.com> - 2011-05-19 21:24 +0100
Re: '5'-'0' = 5 alway? guaranteed? "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> - 2011-05-20 00:39 +0200
| From | "crea" <no@invalid.com> |
|---|---|
| Date | 2011-05-19 20:13 +0100 |
| Subject | '5'-'0' = 5 alway? guaranteed? |
| Message-ID | <t_dBp.16910$7H.13151@newsfe08.ams2> |
I am just programming this kind of thing, and was wondering I according to c++ language it is always guaranteed that '5'-'0' = 5. Character calculations. Because character should be in order isnt it? Is it guaranteed that they are in order and the difference is 1?
[toc] | [next] | [standalone]
| From | "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> |
|---|---|
| Date | 2011-05-19 21:28 +0200 |
| Message-ID | <ir3qlq$a84$1@dont-email.me> |
| In reply to | #5179 |
* crea, on 19.05.2011 21:13: > I am just programming this kind of thing, and was wondering I according to > c++ language it is always guaranteed that > '5'-'0' = 5. Character calculations. Because character should be in order > isnt it? Is it guaranteed that they are in order and the difference is 1? Yes. But that does not hold for letters (which are discontiguous in EBCDIC, which the C++ standard "must" support). Cheers & hth., - Alf -- blog at <url: http://alfps.wordpress.com>
[toc] | [prev] | [next] | [standalone]
| From | "crea" <no@invalid.com> |
|---|---|
| Date | 2011-05-19 20:35 +0100 |
| Message-ID | <vieBp.666$Ky.145@newsfe24.ams2> |
| In reply to | #5180 |
"Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> wrote in message news:ir3qlq$a84$1@dont-email.me... >* crea, on 19.05.2011 21:13: >> I am just programming this kind of thing, and was wondering I according >> to >> c++ language it is always guaranteed that >> '5'-'0' = 5. Character calculations. Because character should be in order >> isnt it? Is it guaranteed that they are in order and the difference is 1? > > Yes. > > But that does not hold for letters (which are discontiguous in EBCDIC, > which the C++ standard "must" support). > ok, good to know also the letter-thing.
[toc] | [prev] | [next] | [standalone]
| From | Noah Roberts <dont@email.me> |
|---|---|
| Date | 2011-05-19 12:58 -0700 |
| Message-ID | <4dd5764b$0$2413$cc2e38e6@news.uslec.net> |
| In reply to | #5181 |
On 5/19/2011 12:35 PM, crea wrote: > "Alf P. Steinbach /Usenet"<alf.p.steinbach+usenet@gmail.com> wrote in > message news:ir3qlq$a84$1@dont-email.me... >> * crea, on 19.05.2011 21:13: >>> I am just programming this kind of thing, and was wondering I according >>> to >>> c++ language it is always guaranteed that >>> '5'-'0' = 5. Character calculations. Because character should be in order >>> isnt it? Is it guaranteed that they are in order and the difference is 1? >> >> Yes. >> >> But that does not hold for letters (which are discontiguous in EBCDIC, >> which the C++ standard "must" support). >> > > ok, good to know also the letter-thing. > > He's wrong actually. It's a really good bet, but by no means guaranteed. -- http://crazycpp.wordpress.com
[toc] | [prev] | [next] | [standalone]
| From | Victor Bazarov <v.bazarov@comcast.invalid> |
|---|---|
| Date | 2011-05-19 16:10 -0400 |
| Message-ID | <ir3tf8$tbq$1@dont-email.me> |
| In reply to | #5182 |
On 5/19/2011 3:58 PM, Noah Roberts wrote: > On 5/19/2011 12:35 PM, crea wrote: >> "Alf P. Steinbach /Usenet"<alf.p.steinbach+usenet@gmail.com> wrote in >> message news:ir3qlq$a84$1@dont-email.me... >>> * crea, on 19.05.2011 21:13: >>>> I am just programming this kind of thing, and was wondering I according >>>> to >>>> c++ language it is always guaranteed that >>>> '5'-'0' = 5. Character calculations. Because character should be in >>>> order >>>> isnt it? Is it guaranteed that they are in order and the difference >>>> is 1? >>> >>> Yes. >>> >>> But that does not hold for letters (which are discontiguous in EBCDIC, >>> which the C++ standard "must" support). >>> >> >> ok, good to know also the letter-thing. >> >> > > He's wrong actually. It's a really good bet, but by no means guaranteed. No, he is not. Read [lex.charset]/3. Carefully. V -- I do not respond to top-posted replies, please don't ask
[toc] | [prev] | [next] | [standalone]
| From | Pete Becker <pete@versatilecoding.com> |
|---|---|
| Date | 2011-05-19 16:21 -0400 |
| Message-ID | <2011051916213466006-pete@versatilecodingcom> |
| In reply to | #5182 |
On 2011-05-19 15:58:29 -0400, Noah Roberts said: > On 5/19/2011 12:35 PM, crea wrote: >> "Alf P. Steinbach /Usenet"<alf.p.steinbach+usenet@gmail.com> wrote in >> message news:ir3qlq$a84$1@dont-email.me... >>> * crea, on 19.05.2011 21:13: >>>> I am just programming this kind of thing, and was wondering I according >>>> to >>>> c++ language it is always guaranteed that >>>> '5'-'0' = 5. Character calculations. Because character should be in order >>>> isnt it? Is it guaranteed that they are in order and the difference is 1? >>> >>> Yes. >>> >>> But that does not hold for letters (which are discontiguous in EBCDIC, >>> which the C++ standard "must" support). >>> >> >> ok, good to know also the letter-thing. >> >> > > He's wrong actually. It's a really good bet, but by no means guaranteed. The character representations of the digits 0-9 are required to be contiguous and in ascending order. And there's no similar requirement for any other characters. -- Pete Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The Standard C++ Library Extensions: a Tutorial and Reference (www.petebecker.com/tr1book)
[toc] | [prev] | [next] | [standalone]
| From | "crea" <no@invalid.com> |
|---|---|
| Date | 2011-05-19 21:24 +0100 |
| Message-ID | <B0fBp.630$8_2.271@newsfe17.ams2> |
| In reply to | #5185 |
"Pete Becker" <pete@versatilecoding.com> wrote in message news:2011051916213466006-pete@versatilecodingcom... > On 2011-05-19 15:58:29 -0400, Noah Roberts said: >>> >>> ok, good to know also the letter-thing. >>> >>> >> >> He's wrong actually. It's a really good bet, but by no means guaranteed. > > The character representations of the digits 0-9 are required to be > contiguous and in ascending order. And there's no similar requirement for > any other characters. > Thanks guys, good info which would be difficult to find from books (well, maybe google would help but this is not something which is told in schools or books) - yes, they use it sometimes, but I never read that its "guaranteed to work" which I really need to know.
[toc] | [prev] | [next] | [standalone]
| From | "Alf P. Steinbach /Usenet" <alf.p.steinbach+usenet@gmail.com> |
|---|---|
| Date | 2011-05-20 00:39 +0200 |
| Message-ID | <ir45rn$n1k$1@dont-email.me> |
| In reply to | #5182 |
* Stefan Ram, on 19.05.2011 22:09: > Noah Roberts<dont@email.me> writes: >> He's wrong actually. It's a really good bet, but by no means guaranteed. > > Then how for any digit character c, the expression > (do_narrow(c,dfault)-'0') evaluates to the digit value of > the character? (according to ISO/IEC 14882:2003(E) > 22.2.1.1.2 char do_narrow(charT c, char dfault) const, > Effects) Noah is in my killfile so I don't see his article. And he knows that. And needless to say, Noah's public insinuation that I was guessing, knowing full well that I don't see his article, is just what one can expect from him. If you want to check out the formal it's at the very start of the standard somewhere . You can download the latest draft (of the next standard) from the committee pages. Cheers & hth., - Alf -- blog at <url: http://alfps.wordpress.com>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web