View mode: basic / threaded / horizontal-split · Log in · Help
May 25, 2004
Re: Octals
Andy Friesen wrote:
> 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.

I like that.

Never quite warmed up to the idea that two ways to write the same number 
(mathematically speaking) produce a different result in D (e.g. 0042 is 
octal and 42 is decimal). 0o solves that. The consistency with 0x is a 
also a nice property.

Hauke
May 25, 2004
Re: Octals
"Roberto Mariottini" <Roberto_member@pathlink.com> wrote in message
news:c8utl4$2u71$1@digitaldaemon.com...
> 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.

That's why I don't want to change it - the subtle break in semantics.

> 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).

I run into it just often enough.
May 25, 2004
Re: Octals
i'd prefer to break it. i had more subtle breaks of my code because i forgot
to remember that 0 in front fucks up my numbers.

0xNUMBER == hex
0dNUMBER == dec (==NUMBER)
0oNUMBER == oct
0bNUMBER == binary

others?

"Walter" <newshound@digitalmars.com> schrieb im Newsbeitrag
news:c90127$1mi3$2@digitaldaemon.com...
>
> "Roberto Mariottini" <Roberto_member@pathlink.com> wrote in message
> news:c8utl4$2u71$1@digitaldaemon.com...
> > 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.
>
> That's why I don't want to change it - the subtle break in semantics.
>
> > 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).
>
> I run into it just often enough.
>
>
May 25, 2004
Re: Octals
That shouldn't be a problem to implement. Do we want that?

davepermen wrote:
> i'd prefer to break it. i had more subtle breaks of my code because i forgot
> to remember that 0 in front fucks up my numbers.
> 
> 0xNUMBER == hex
> 0dNUMBER == dec (==NUMBER)
> 0oNUMBER == oct
> 0bNUMBER == binary
> 
> others?
>
May 26, 2004
Re: Octals
depends whether unprefixed numbers still represent decimal, or are now errors.

I would be in favour of the following valid forms

   0x90AB    -    hex
   0d7890    -    decimal
   0o6701    -    octal
   0b1010    -    binary

_and_

   7890        -    decimal

With 06701 for octal being invalid

"Stephan Wienczny" <wienczny@web.de> wrote in message
news:c90ckl$28pr$1@digitaldaemon.com...
> That shouldn't be a problem to implement. Do we want that?
>
> davepermen wrote:
> > i'd prefer to break it. i had more subtle breaks of my code because i forgot
> > to remember that 0 in front fucks up my numbers.
> >
> > 0xNUMBER == hex
> > 0dNUMBER == dec (==NUMBER)
> > 0oNUMBER == oct
> > 0bNUMBER == binary
> >
> > others?
> >
May 26, 2004
Re: Octals
Works fer me.


In article <c90oc6$2r0n$1@digitaldaemon.com>, Matthew says...
>
>depends whether unprefixed numbers still represent decimal, or are now errors.
>
>I would be in favour of the following valid forms
>
>    0x90AB    -    hex
>    0d7890    -    decimal
>    0o6701    -    octal
>    0b1010    -    binary
>
>_and_
>
>    7890        -    decimal
>
>With 06701 for octal being invalid
>
>"Stephan Wienczny" <wienczny@web.de> wrote in message
>news:c90ckl$28pr$1@digitaldaemon.com...
>> That shouldn't be a problem to implement. Do we want that?
>>
>> davepermen wrote:
>> > i'd prefer to break it. i had more subtle breaks of my code because i forgot
>> > to remember that 0 in front fucks up my numbers.
>> >
>> > 0xNUMBER == hex
>> > 0dNUMBER == dec (==NUMBER)
>> > 0oNUMBER == oct
>> > 0bNUMBER == binary
>> >
>> > others?
>> >
>
>
May 26, 2004
Re: Octals
Juan C wrote:
> Works fer me.
> 
> 
> In article <c90oc6$2r0n$1@digitaldaemon.com>, Matthew says...
> 
>>depends whether unprefixed numbers still represent decimal, or are now errors.
>>
>>I would be in favour of the following valid forms
>>
>>   0x90AB    -    hex
>>   0d7890    -    decimal
>>   0o6701    -    octal
>>   0b1010    -    binary
>>
>>_and_
>>
>>   7890        -    decimal

What about:

     0u3091    -    unicode

>>With 06701 for octal being invalid
>>
>>"Stephan Wienczny" <wienczny@web.de> wrote in message
>>news:c90ckl$28pr$1@digitaldaemon.com...
>>
>>>That shouldn't be a problem to implement. Do we want that?
>>>
>>>davepermen wrote:
>>>
>>>>i'd prefer to break it. i had more subtle breaks of my code because i forgot
>>>>to remember that 0 in front fucks up my numbers.
>>>>
>>>>0xNUMBER == hex
>>>>0dNUMBER == dec (==NUMBER)
>>>>0oNUMBER == oct
>>>>0bNUMBER == binary
>>>>
>>>>others?
>>>>
>>
>>
> 
>
May 26, 2004
Re: Octals
"Andrew Edwards" <ridimz_at@yahoo.dot.com> wrote in message
news:c90po8$2soc$1@digitaldaemon.com...
> Juan C wrote:
> > Works fer me.
> >
> >
> > In article <c90oc6$2r0n$1@digitaldaemon.com>, Matthew says...
> >
> >>depends whether unprefixed numbers still represent decimal, or are now
errors.
> >>
> >>I would be in favour of the following valid forms
> >>
> >>   0x90AB    -    hex
> >>   0d7890    -    decimal
> >>   0o6701    -    octal
> >>   0b1010    -    binary
> >>
> >>_and_
> >>
> >>   7890        -    decimal
>
> What about:
>
>       0u3091    -    unicode

Not sure what that would do? Is it a character? What base is it in?

I'm not saying I don't like it. Just need to understand it more. :)
May 26, 2004
Re: Octals
In article <c90oc6$2r0n$1@digitaldaemon.com>, Matthew says...
>
>depends whether unprefixed numbers still represent decimal, or are now errors.
>
>I would be in favour of the following valid forms
>
>    0x90AB    -    hex
>    0d7890    -    decimal
>    0o6701    -    octal
>    0b1010    -    binary
>
>_and_
>
>    7890        -    decimal
>
>With 06701 for octal being invalid
>
>"Stephan Wienczny" <wienczny@web.de> wrote in message
>news:c90ckl$28pr$1@digitaldaemon.com...
>> That shouldn't be a problem to implement. Do we want that?
>>
>> davepermen wrote:
>> > i'd prefer to break it. i had more subtle breaks of my code because i forgot
>> > to remember that 0 in front fucks up my numbers.
>> >
>> > 0xNUMBER == hex
>> > 0dNUMBER == dec (==NUMBER)
>> > 0oNUMBER == oct
>> > 0bNUMBER == binary
>> >
>> > others?
>> >
>
>
I'm for it too! (+1)
May 26, 2004
Re: Octals
Matthew wrote:

> depends whether unprefixed numbers still represent decimal, or are now errors.
> 
> I would be in favour of the following valid forms
> 
>     0x90AB    -    hex
>     0d7890    -    decimal
>     0o6701    -    octal
>     0b1010    -    binary
> 
> _and_
> 
>     7890        -    decimal
> 
> With 06701 for octal being invalid
<snip>

Do you mean it would be an illegal token?  This is indeed the only way 
we can sensibly change this.

-- 
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.
1 2 3 4 5
Top | Discussion index | About this forum | D home