Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #112096
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Hexadecimal float constants |
| Date | 2017-06-12 16:01 -0700 |
| Organization | None to speak of |
| Message-ID | <lnshj4g69r.fsf@kst-u.example.com> (permalink) |
| References | <ohmfqn$q4l$1@gioia.aioe.org> <3ebbcdb0-2c89-8e08-43a3-c54fe22fe426@verizon.net> <b71d7769-536a-487d-a141-b7b1214362df@googlegroups.com> <lna85dgj0b.fsf@kst-u.example.com> <ff149710-bb43-445e-a2f1-cc0974921344@googlegroups.com> |
supercat@casperkitty.com writes:
> On Monday, June 12, 2017 at 1:26:19 PM UTC-5, Keith Thompson wrote:
>> How so? I can't think of any other tokenization than a ++ + ++ b that
>> would yield a syntactically valid expression, regardless of how `a` is
>> declared/defined. (Of course the standard requires it to be tokenized
>> as a ++ ++ + b, which is a syntax error, again regardless of how `a` and
>> `b` are delcared/defined.)
>
> If a is an array and b is an int, the expression would be valid if
> tokenized as either "a + + + ++ b" or "a + + + + + b". If a is an int
> and b is an array, it would be valid if tokenized as "a ++ + + + b" or
> "a + + + + + b". In neither case would "a++ + ++b" be a valid parse.
I hadn't thought about the unary "+" operator, but you've snipped
relevant context. You were talking about *parsing*, not about whether
the expression might be invalid for other reasons.
Yes, `a + + + + + b` can be valid if a and b are of numeric type.
[...]
>> 1.23E+5 is a perfectly valid floating constant. The example we were
>> discussing was 0x1234e-1 .
>
> The simplest way to make floating-point numbers like 1.23E+5 "work" would
> be to treat such values as a sequence of tokens and then have the parser
> assemble them.
The language already defines how 1.23E+5 works. We recently spent a
great deal of time discussing the minor glitch involving preprocessing
numbers like `0x1234e-1`. It is, in my opinion, not a problem worth
solving.
[...]
> Implementations are free to add extensions provided that they document them,
> and provided that they don't interfere with the behavior of any strictly-
> conforming program. Since the documentation requirement would be
> meaningless in cases where use of an extension would trigger a diagnostic,
> the only way in which the permission to include extensions would be
> meaningful would be if documented extensions are exempt from the diagnostic
> requirement.
>
> One could argue that implementations wanting to document as an extension
> their acceptance of 0x1e+x as equivalent to "0x1e + x" would be required
> to ensure that sequence of characters behaves as a single token in cases
> where a strictly-conforming program defines x as a macro and that sequence
> of characters is stringized after macro substitution, but I see no useful
> purpose to be served by requiring such behavior.
Wait, now you're talking about "0x1e+x"? Where did that final "x" come
from?
An implementation could have an extension whereby it treats `0x1e+x` as
equivalent to `0x1e + x`. Having and documenting such an extension does
not relieve it of the requirement to diagnose `0x1e+x` as a constraint
violation. It can issue a non-fatal warning and then proceed to treat
it as `0x1e+x`, and/or it can do so without a warning in some
non-conforming mode.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
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