Velocity Reviews > C++ > Is 0 a decimal integer?

# Is 0 a decimal integer?

Steven T. Hatton
Guest
Posts: n/a

 07-23-2005
I say no, 0 is _not_ a decimal literal. Anybody disagree? If you do agree
with me, then what do you think it is?
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell

benben
Guest
Posts: n/a

 07-23-2005
Doesn't 0 mathematically mean 0 (zero, null, nil) in decimal, binary,
hexadecimal, etc whatever number system you can devise?

Ben

Steven T. Hatton
Guest
Posts: n/a

 07-23-2005
benben wrote:

> Doesn't 0 mathematically mean 0 (zero, null, nil) in decimal, binary,
> hexadecimal, etc whatever number system you can devise?
>
> Ben

I'm speaking strictly in lexical terms. How would a C++ grammarian classify
0? I believe you are correct regarding semantics.

--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell

Ron Natalie
Guest
Posts: n/a

 07-23-2005
Steven T. Hatton wrote:
> I say no, 0 is _not_ a decimal literal. Anybody disagree? If you do agree
> with me, then what do you think it is?

A naked 0 is a octal-literal according to the C++ standard.
A decimimal literal is a single non-zero digit followed
by zero or more digits.

Steven T. Hatton
Guest
Posts: n/a

 07-23-2005
Ron Natalie wrote:

> Steven T. Hatton wrote:
>> I say no, 0 is _not_ a decimal literal. Anybody disagree? If you do
>> agree with me, then what do you think it is?

>
> A naked 0 is a octal-literal according to the C++ standard.
> A decimimal literal is a single non-zero digit followed
> by zero or more digits.

It's probably a completely pointless observation, but that's also how I
understood §2.13.1.
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell

M.Pfeifer
Guest
Posts: n/a

 07-23-2005

"Steven T. Hatton" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> benben wrote:
>
> > Doesn't 0 mathematically mean 0 (zero, null, nil) in decimal, binary,
> > hexadecimal, etc whatever number system you can devise?
> >
> > Ben

>
> I'm speaking strictly in lexical terms. How would a C++ grammarian

classify
> 0? I believe you are correct regarding semantics.
>

You have to use a type qualifier. So it depends on you.

I think

(char) 0

would be valid as well. But I didn't check it.

Matthias

Starfox
Guest
Posts: n/a

 07-23-2005
As much as I think this is pointless, this might solve the argument,
sort of:

std::cout << typeid(0).name();

Steven T. Hatton
Guest
Posts: n/a

 07-23-2005
Starfox wrote:

> As much as I think this is pointless, this might solve the argument,
> sort of:
>
> std::cout << typeid(0).name();

Not really, because an octal integer literal will result in the creation of
a temporary of type int.
--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell

Jack Klein
Guest
Posts: n/a

 07-24-2005
On Sat, 23 Jul 2005 06:38:41 -0400, "Steven T. Hatton"
<(E-Mail Removed)> wrote in comp.lang.c++:

> I say no, 0 is _not_ a decimal literal. Anybody disagree? If you do agree
> with me, then what do you think it is?

I think you are wasting the group's time playing with silly newbie
exercises. Suppose some particular compiler gets it wrong, and parses
it as a decimal literal. How could you tell the difference?

--
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.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html

Steven T. Hatton
Guest
Posts: n/a

 07-24-2005
Jack Klein wrote:

> On Sat, 23 Jul 2005 06:38:41 -0400, "Steven T. Hatton"
> <(E-Mail Removed)> wrote in comp.lang.c++:
>
>> I say no, 0 is _not_ a decimal literal. Anybody disagree? If you do
>> agree with me, then what do you think it is?

>
> I think you are wasting the group's time playing with silly newbie
> exercises. Suppose some particular compiler gets it wrong, and parses
> it as a decimal literal. How could you tell the difference?

..

--
If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true.-Bertrand Russell