Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 25, 2004 Octals | ||||
---|---|---|---|---|
| ||||
From the specs: " Octal integers are a sequence of octal digits preceded by a '0'." I wanted to verify that octal is represented by digits preceded by a zero, as the spec says. Is this true? |
May 25, 2004 Re: Octals | ||||
---|---|---|---|---|
| ||||
Posted in reply to DemmeGod | "DemmeGod" <me@demmegod.com> wrote in message news:pan.2004.05.25.01.03.32.701233@demmegod.com... > From the specs: > " Octal integers are a sequence of octal digits preceded by a '0'." > > I wanted to verify that octal is represented by digits preceded by a zero, as the spec says. Is this true? Yes. |
May 25, 2004 Re: Octals | ||||
---|---|---|---|---|
| ||||
Posted in reply to DemmeGod | An octal looks like this
01
07
0123
or this
\1 \7 \123
By the way you don't believe Walter?
DemmeGod wrote:
> From the specs:
> " Octal integers are a sequence of octal digits preceded by a '0'."
>
> I wanted to verify that octal is represented by digits preceded by a zero,
> as the spec says. Is this true?
|
May 25, 2004 Re: Octals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | From Specs:
" Octal:
0 OctalDigits"
That zero looked like an uppercase 'o' in my browser. Just wanted to make sure.
On Tue, 25 May 2004 03:11:50 +0200, Stephan Wienczny wrote:
> An octal looks like this
>
> 01
> 07
> 0123
>
> or this
>
> \1 \7 \123
>
> By the way you don't believe Walter?
>
> DemmeGod wrote:
>> From the specs:
>> " Octal integers are a sequence of octal digits preceded by a '0'."
>>
>> I wanted to verify that octal is represented by digits preceded by a zero, as the spec says. Is this true?
|
May 25, 2004 Re: Octals | ||||
---|---|---|---|---|
| ||||
Posted in reply to DemmeGod | On Mon, 24 May 2004 21:03:33 -0400, DemmeGod wrote:
> From the specs:
> " Octal integers are a sequence of octal digits preceded by a '0'."
>
> I wanted to verify that octal is represented by digits preceded by a zero, as the spec says. Is this true?
Why not try it?
int main(char[][] args) { int x = 0777; return 0; }
It'll take a lot less time than posting.
Mike Swieton
__
You can have peace. Or you can have freedom. Don't ever count on having
both at once.
- Lazarus Long (Robert A. Heinlein)
|
May 25, 2004 Re: Octals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | >An octal looks like this
>
>01
>07
>0123
>
>or this
>
>\1 \7 \123
>
BTW, what about deprecating octals starting with 0?
I keep winning bets with C and C++ programmers about 010 == 8 (some old C
compilers accepted 010 == 08), but it's a bit annoying.
Many beginners start aligning numbers with leading 0s just to discover that it
doesn't work for historical reasons unknown to the most.
Moreover I don't see any practical use for octal numbers nowadays, and I don't think it's worth supporting them for very old legacy C code (that has to be rewritten anyway IMHO).
Ciao
|
May 25, 2004 Re: Octals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Swieton | Mike Swieton wrote: <snip> > Why not try it? > > int main(char[][] args) { int x = 0777; return 0; } > > It'll take a lot less time than posting. Depends on whether D compiler and Internet connection are in the same place, as mine aren't for instance. But it's also quite simple to c&p stuff from a typical browser into something that lets you see it in a font that clearly distinguishes O and 0. (Of course, messing with browser settings also tends to work, though not always.) Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit. |
May 25, 2004 Re: Octals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | Roberto Mariottini wrote:
>>An octal looks like this
>>
>>01
>>07
>>0123
>>
>>or this
>>
>>\1 \7 \123
>>
>
>
> BTW, what about deprecating octals starting with 0?
>
> I keep winning bets with C and C++ programmers about 010 == 8 (some old C
> compilers accepted 010 == 08), but it's a bit annoying.
> Many beginners start aligning numbers with leading 0s just to discover that it
> doesn't work for historical reasons unknown to the most.
>
> Moreover I don't see any practical use for octal numbers nowadays, and I don't
> think it's worth supporting them for very old legacy C code (that has to be
> rewritten anyway IMHO).
Octal numbers still have their uses here and there. (like Unix file permission attributes)
I wouldn't be against changing the syntax, though. How about 0o10 == 10? It's somewhat symmetrical with the 0x hex notation, and is clearly not a decimal integer.
-- andy
|
May 25, 2004 Re: Octals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | >I wouldn't be against changing the syntax, though. How about 0o10 == 10? It's somewhat symmetrical with the 0x hex notation, and is clearly not a decimal integer.
I like that, but don't you nean 0o10 == 8 (decimal)? And then mightn't it be possible to remove that leading zero from these and hexes as redundant?
|
May 25, 2004 Re: Octals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juan C | The leading 0 makes it easier to lex.
If you find a 0 you know it will be a number. If you only had o what would you do in this case:
o123
This is an valid identifier and if we drop the 0 a valid number ;-(
Stephan
Juan C wrote:
>>I wouldn't be against changing the syntax, though. How about 0o10 == 10? It's somewhat symmetrical with the 0x hex notation, and is clearly not a decimal integer.
>
>
> I like that, but don't you nean 0o10 == 8 (decimal)? And then mightn't it be
> possible to remove that leading zero from these and hexes as redundant?
>
>
|
Copyright © 1999-2021 by the D Language Foundation