Topic: base for exponents
Author: Jerry Coffin <jcoffin@taeus.com>
Date: 2000/02/19 Raw View
In article <PIcWOEAaXbr4EwRR@robinton.demon.co.uk>,
francis@robinton.demon.co.uk says...
>
> At a meeting today (about C) the question was raised about what ensures
> that the following is interpreted as most would expect (there is wording
> in C99 that is intended to do this)
>
> double d = 1E011;
>
> What in the C++ standard forbids that being taken as equivalent to:
>
> double d = 1E9;
I don't think there is one -- in fact, it looks to me like it's
_required_ to be that way since the exponent is only specified to be
an "optionally signed integer" and only the integer part and fraction
part are specified to be "decimal (base 10) digits." Absent any
statement to the contrary, it seems to me an "optionally signed
integer" should be treated like any other integer literal, as
specified in 2.13.1, in which case a leading 0 signifies octal, just
as you've said.
--
Later,
Jerry.
The universe is a figment of its own imagination.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Steve Clamage <stephen.clamage@sun.com>
Date: 2000/02/19 Raw View
Francis Glassborow wrote:
>
> At a meeting today (about C) the question was raised about what ensures
> that the following is interpreted as most would expect (there is wording
> in C99 that is intended to do this)
>
> double d = 1E011;
>
> What in the C++ standard forbids that being taken as equivalent to:
>
> double d = 1E9;
>
Hmmm. The C89 standard (6.1.3.1) says the exponent part is interpreted
as a decimal integer. The C++ standard (2.13.3) neglects to say "decimal".
Looks like an oversight to me.
--
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 2000/02/20 Raw View
In article <38ADD3E3.1213E454@sun.com>, Steve Clamage
<stephen.clamage@sun.com> writes
>Hmmm. The C89 standard (6.1.3.1) says the exponent part is interpreted
>as a decimal integer. The C++ standard (2.13.3) neglects to say "decimal".
>Looks like an oversight to me.
An C99 says the same thing, but neither actually defines a 'decimal
integer' nor do any of the referenced documents.
Anyway, that looks like a defect to me, and one where simply inserting
'decimal' will not be enough.
>
Francis Glassborow Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Andy Larson <AndyLarson@alum.rpi.edu>
Date: 2000/02/21 Raw View
I see no defect here. The C++ standard (2.13.3) defines the
exponent-part to be either
e sign(opt) digit-sequence
or
E sign(opt) digit-sequence
digit-sequence is definded to be one or more digits and digit is defined
(2.10) to be only the decimal digits. As a result, an octal value for
the exponent is a syntax error.
Andy Larson
Francis Glassborow wrote:
>
> In article <38ADD3E3.1213E454@sun.com>, Steve Clamage
> <stephen.clamage@sun.com> writes
> >Hmmm. The C89 standard (6.1.3.1) says the exponent part is interpreted
> >as a decimal integer. The C++ standard (2.13.3) neglects to say "decimal".
> >Looks like an oversight to me.
>
> An C99 says the same thing, but neither actually defines a 'decimal
> integer' nor do any of the referenced documents.
>
> Anyway, that looks like a defect to me, and one where simply inserting
> 'decimal' will not be enough.
>
> >
>
> Francis Glassborow Journal Editor, Association of C & C++ Users
> 64 Southfield Rd
> Oxford OX4 1PA +44(0)1865 246490
> All opinions are mine and do not represent those of any organisation
>
> ---
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
> [ --- Please see the FAQ before posting. --- ]
> [ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
======================================= MODERATOR'S COMMENT:
Please do not overquote. In particular, the .sig and moderation
banner should not be quoted.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 2000/02/22 Raw View
In article <88n1i3$anem$1@newssvr03-int.news.prodigy.com>, Andy Larson
<AndyLarson@alum.rpi.edu> writes
>I see no defect here. The C++ standard (2.13.3) defines the
>exponent-part to be either
>
>e sign(opt) digit-sequence
>
>or
>
>E sign(opt) digit-sequence
>
>digit-sequence is definded to be one or more digits and digit is defined
>(2.10) to be only the decimal digits. As a result, an octal value for
>the exponent is a syntax error.
The production for digit-sequence does not as far as I can see prohibit
a leading zero. However elsewhere a digit sequence with a leading zero
is stated to be either an octal integer or a hexadecimal integer
depending on the following character. Granted that 08 and 09 are syntax
errors but 011 is not and AFAICS evaluates to 9 everywhere and that
would be a surprise in the context of an exponent and a difference with
C. However I note that C++ does (unlike C) define a decimal integer but
that is not equivalent to a decimal sequence.
>
>Andy Larson
Francis Glassborow Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 2000/02/22 Raw View
Andy Larson wrote:
>
> I see no defect here. The C++ standard (2.13.3) defines the
> exponent-part to be either
>
> e sign(opt) digit-sequence
>
> or
>
> E sign(opt) digit-sequence
>
> digit-sequence is definded to be one or more digits and digit is defined
> (2.10) to be only the decimal digits. As a result, an octal value for
> the exponent is a syntax error.
Octal literals are written using decimal digits. The only way they can
be distinguished from decimal literals is the leading 0 which is
mandatory in octal literals, and prohibited in decimal literals (some
decimal literals can be distinguished by the fact that they contain '8'
or '9', but that's going in the wrong direction for this discussion).
Therefore, in order for an octal value to be excluded as a syntax error
in the exponent, the standard would have to prohibit exponents that
start with '0'. That's not what 2.13.3 says - any digit sequence is
allowed, with or without a leading '0'. It's very careful to specify
that the integer part and the fractional parts are decimal numbers; the
corresponding silence with respect to the exponent leads me to wonder if
it was deliberate.
....
> Francis Glassborow wrote:
> >
> > In article <38ADD3E3.1213E454@sun.com>, Steve Clamage
> > <stephen.clamage@sun.com> writes
> > >Hmmm. The C89 standard (6.1.3.1) says the exponent part is interpreted
> > >as a decimal integer. The C++ standard (2.13.3) neglects to say "decimal".
> > >Looks like an oversight to me.
> >
> > An C99 says the same thing, but neither actually defines a 'decimal
> > integer' nor do any of the referenced documents.
The phrase 'decimal integer' has a sufficiently well-defined meaning in
mathematics that I think a definition isn't needed, unless the
definition were different from that of ordinary mathematical usage.
> > Anyway, that looks like a defect to me, and one where simply inserting
> > 'decimal' will not be enough.
Now, Francis is suggesting that an octal value was prohibited in C89 as
a matter of semantics, not syntax. Since the C89 standard said
"decimal", exponents that were integer literals with a leading '0' would
be interpreted as decimal literals, even though they'd be interpreted as
octal literals if they were standing alone.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Barry Margolin <barmar@bbnplanet.com>
Date: 2000/02/22 Raw View
In article <9JwKOzApoqr4Ewmt@robinton.demon.co.uk>,
Francis Glassborow <francisG@robinton.demon.co.uk> wrote:
>In article <38ADD3E3.1213E454@sun.com>, Steve Clamage
><stephen.clamage@sun.com> writes
>>Hmmm. The C89 standard (6.1.3.1) says the exponent part is interpreted
>>as a decimal integer. The C++ standard (2.13.3) neglects to say "decimal".
>>Looks like an oversight to me.
>
>An C99 says the same thing, but neither actually defines a 'decimal
>integer' nor do any of the referenced documents.
>
>Anyway, that looks like a defect to me, and one where simply inserting
>'decimal' will not be enough.
If the standard doesn't define a term, its meaning is taken from more
general standards (I think there's an ISO standard glossary for computer
terminology), and if it's not there its normal English definition is
assumed. I can't imagine that "decimal integer" would be ambiguous and
need a specific definition in the C++ standard.
--
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Martin von Loewis <loewis@informatik.hu-berlin.de>
Date: 2000/02/24 Raw View
Francis Glassborow <francis@robinton.demon.co.uk> writes:
> An C99 says the same thing, but neither actually defines a 'decimal
> integer' nor do any of the referenced documents.
However, the C99 standard clearly means 'decimal integer constant',
which is defined in 6.4.4.1. That defines the 'usual' meaning of
decimal, octal and hexadecimal integral numbers; I see no point in
repeating that definition whereever the term is used.
> Anyway, that looks like a defect to me, and one where simply
> inserting 'decimal' will not be enough.
For C++, I'd agree it is a defect. I'd think that adding decimal would
specify the intended meaning sufficiently.
If you want to be overly formal, you'd have to fix a lot of other
places as well. Consider 2.13.2, [lex.ccon]/4, where is says that \ooo
consists of three octal digits, but fails to say that they are
understood as a base-8 number, with the left-most position being most
signifcant. The same holds for \xhhh.
Regards,
Martin
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]