Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Motion 46: finalise interval literals



Yes, a 0 prefix means octal in C and C++.  In C 99 it's in section 6.4.4.1 Integer Constants:

    octal-constant:
        0
        octal-constant octal-digit
    . . .
   An octal constant consists of the prefix 0 optionally followed by a sequence of the
    digits 0 through 7 only.

There are also octal escape sequences in character constants and therefore also in string literals:

    octal-escape-sequence:
    \ octal-digit
    \ octal-digit octal-digit
    \ octal-digit octal-digit octal-digit


Octal isn't heavily used anymore, but at the time of the early implementations of C and Unix octal was very common.  The first Unix was on the DEC PDP-7 / PDP-9 which had an 18 bit word - a multiple of 3 not 4 bits.

I used to be able to do octal arithmetic in my head, but now I'd like to see it dropped.  That's difficult - first it would have to be debated by both standards committees for 010 years then deprecated for 0100 years.

- Ian McIntosh          IBM Canada Lab         Compiler Back End Support and Development


Inactive hide details for John Pryce ---07/12/2013 06:03:08 AM---On 12 Jul 2013, at 08:42, Vincent Lefevre wrote: >> I think thJohn Pryce ---07/12/2013 06:03:08 AM---On 12 Jul 2013, at 08:42, Vincent Lefevre wrote: >> I think that this phrase from the text is suffic


    From:

John Pryce <j.d.pryce@xxxxxxxxxx>

    To:

Ian McIntosh/Toronto/IBM@IBMCA

    Date:

07/12/2013 06:03 AM

    Subject:

Re: Motion 46: finalise interval literals





On 12 Jul 2013, at 08:42, Vincent Lefevre wrote:
>> I think that this phrase from the text is sufficient:
>> "One ulp equals one unit in the last place of the number m as written."
>
> Perhaps, however it isn't very well said: "the number m as written"
> still refers to a number, not a string or representation. I would
> prefer something like:
>
>  One ulp equals the unit (weight) of the last written digit.

I was brought up from elementary school with "place" having this technical meaning, as in "Ones place", "Tens place", "Hundreds place" etc., so it is actually preciser language than "digit". The "place" is the slot where you write a "digit".

So I prefer to keep "place". However it may not be familiar to non-native English speakers? I would welcome a suggested sentence of explanation to add, along with examples like those below.

>> It defines ulp not in terms of value but in terms of string. So
>> 0? = [-0.5,+0.5]
>> 0.0? = [-0.05,+0.05]
>
> But I think that such examples would be useful.

>> Moreover the grammar doesn't match (1). According to (1), "011" is
>> 9 in C, but according to the grammar, it is 11, in the context of
>> ratNumLit.

Oh dear, this octal convention is C? I thought it was some outlandish language hardly anyone had heard of.

John Pryce



GIF image

GIF image