Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #112076
| Newsgroups | comp.lang.c |
|---|---|
| Date | 2017-06-12 12:39 -0700 |
| References | <ohmfqn$q4l$1@gioia.aioe.org> <3ebbcdb0-2c89-8e08-43a3-c54fe22fe426@verizon.net> <b71d7769-536a-487d-a141-b7b1214362df@googlegroups.com> |
| Message-ID | <e7e9378a-107d-4ea5-82d2-e2ff69f1969e@googlegroups.com> (permalink) |
| Subject | Re: Hexadecimal float constants |
| From | jameskuyper@verizon.net |
On Monday, June 12, 2017 at 1:54:39 PM UTC-4, supe...@casperkitty.com wrote: > On Monday, June 12, 2017 at 11:44:08 AM UTC-5, James R. Kuyper wrote: > > The C89 Committee felt that it was better to tolerate such > > anomalies than burden the preprocessor with a more exact, and exacting, > > lexical specification. It felt that this anomaly was no worse than the > > principle under which the characters a+++++b are tokenized as a ++ ++ + > > b (an invalid expression), even though the tokenization a ++ + ++ b > > would yield a syntactically correct expression. In both cases, exercise > > of reasonable precaution in coding style avoids surprises." You snipped out every indication I made in my message that I was quoting text written by someone else (except for the final '"' character). Please don't do that. It gives the impression that I'm claiming to be the author of those words, which I most certainly didn't. I just cut and pasted them from the Rationale. ... > By contrast, it is unlikely that any non-contrived strictly conforming > programs would rely upon compilers' inability to recognize a token > boundary between a hex constant ending in "E" and a trailing plus sign, That's true: such code is a constraint violation, and therefore cannot occur in strictly conforming code. ... > Fun puzzle: produce a strictly-conforming program which would return 1 on > an implementation that conforms to the standard, and 0 on an implementation > that would regard a + or - sign that follows any hex constant as a token > boundary, even if the last digit of the constant happens to be "e" or "E". > It is possible, but I would think it unlikely that any such programs have > ever been written except for compiler testing or other contrived purposes. "Each preprocessing token that is converted to a token shall have the lexical form of a keyword, an identifier, a constant, a string literal, or a punctuator." 6.4p2. A hexadecimal constant immediately followed by a + or - would be parsed as a pp-number (6.4.8), possibly including some following characters, when preprocessing tokens are identified. It would therefore be parsed as a single preprocessing token. When the attempt is made to convert it to an ordinary token, it can never qualify as any of tho things listed in 6.4p2. Hexadecimal constants necessarily start with 0x (6.4.4.1p1). No identifier, character constant, string literal, or punctuator can start with a 0x (6.4.1, 6.4.2, 6.4.4.4p1), 6.4.6p1. The only types of numeric constants that can start with 0x and also contain a '+' or a '-' are floating point constants, but in that case, the '+' or '-' must be immediately preceded by 'p' or 'P' (6.4.4.2p1). Neither of those characters is allowed in a hexadecimal constant. (6.4.4.1p1). Therefore, any "+ or - sign that follows any hex constant" without any white space to separate them is a constraint violation, and therefore cannot appear in strictly conforming code.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Hexadecimal float constants Steve Keller <keller@no.invalid> - 2017-06-12 18:34 +0200
Re: Hexadecimal float constants "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-12 12:44 -0400
Re: Hexadecimal float constants supercat@casperkitty.com - 2017-06-12 10:54 -0700
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-12 11:26 -0700
Re: Hexadecimal float constants bartc <bc@freeuk.com> - 2017-06-12 19:38 +0100
Re: Hexadecimal float constants scott@slp53.sl.home (Scott Lurndal) - 2017-06-12 18:45 +0000
Re: Hexadecimal float constants Robert Wessel <robertwessel2@yahoo.com> - 2017-06-12 13:54 -0500
Re: Hexadecimal float constants bartc <bc@freeuk.com> - 2017-06-12 20:40 +0100
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-12 13:06 -0700
Re: Hexadecimal float constants supercat@casperkitty.com - 2017-06-12 13:37 -0700
Re: Hexadecimal float constants bartc <bc@freeuk.com> - 2017-06-12 22:22 +0100
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-12 16:01 -0700
Re: Hexadecimal float constants supercat@casperkitty.com - 2017-06-12 16:36 -0700
Re: Hexadecimal float constants jameskuyper@verizon.net - 2017-06-12 12:39 -0700
Re: Hexadecimal float constants bartc <bc@freeuk.com> - 2017-06-12 18:42 +0100
Re: Hexadecimal float constants Thomas David Rivers <rivers@dignus.com> - 2017-06-12 17:27 -0400
Re: Hexadecimal float constants "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-12 18:03 -0400
Re: Hexadecimal float constants bartc <bc@freeuk.com> - 2017-06-12 23:31 +0100
Re: Hexadecimal float constants Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-13 00:10 +0100
Re: Hexadecimal float constants jacobnavia <jacob@jacob.remcomp.fr> - 2017-06-13 01:33 +0200
Re: Hexadecimal float constants Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-13 01:10 +0100
Re: Hexadecimal float constants supercat@casperkitty.com - 2017-06-12 16:01 -0700
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-12 17:00 -0700
Re: Hexadecimal float constants supercat@casperkitty.com - 2017-06-13 07:51 -0700
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-13 09:17 -0700
Re: Hexadecimal float constants bartc <bc@freeuk.com> - 2017-06-13 17:45 +0100
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-13 11:58 -0700
Re: Hexadecimal float constants supercat@casperkitty.com - 2017-06-13 12:57 -0700
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-13 13:01 -0700
Re: Hexadecimal float constants bartc <bc@freeuk.com> - 2017-06-13 22:11 +0100
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-13 14:22 -0700
Re: Hexadecimal float constants "James R. Kuyper" <jameskuyper@verizon.net> - 2017-06-13 17:43 -0400
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-13 14:48 -0700
Re: Hexadecimal float constants bartc <bc@freeuk.com> - 2017-06-13 23:03 +0100
Re: Hexadecimal float constants GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-06-14 01:30 +0200
Re: Hexadecimal float constants supercat@casperkitty.com - 2017-06-13 12:24 -0700
Re: Hexadecimal float constants jacobnavia <jacob@jacob.remcomp.fr> - 2017-06-13 21:52 +0200
Re: Hexadecimal float constants Keith Thompson <kst-u@mib.org> - 2017-06-13 13:12 -0700
Re: Hexadecimal float constants supercat@casperkitty.com - 2017-06-13 16:18 -0700
Re: Hexadecimal float constants Ike Naar <ike@iceland.freeshell.org> - 2017-06-14 21:28 +0000
Re: Hexadecimal float constants supercat@casperkitty.com - 2017-06-12 15:21 -0700
Re: Hexadecimal float constants Thomas David Rivers <rivers@dignus.com> - 2017-06-13 12:13 -0400
csiph-web