isodigit

Discussion in 'C Programming' started by JoseMariaSola, Nov 19, 2007.

  1. The standard defines isdigit and isxdigit but doesn't say anything
    about isodigit (testing for octal digits).
    Anyone knows why?
    Thanks.
    Joey.
     
    JoseMariaSola, Nov 19, 2007
    #1
    1. Advertising

  2. JoseMariaSola

    Richard Bos Guest

    JoseMariaSola <> wrote:

    > The standard defines isdigit and isxdigit but doesn't say anything
    > about isodigit (testing for octal digits).
    > Anyone knows why?


    No, but it's simple to define, since the Standard does demand that '0'
    through '7' are subsequent.

    Richard
     
    Richard Bos, Nov 19, 2007
    #2
    1. Advertising

  3. > > The standard defines isdigit and isxdigit but doesn't say
    > > anything about isodigit (testing for octal digits).
    > > Anyone knows why?

    > No, but it's simple to define, since the Standard
    > does demand that '0'through '7' are subsequent.

    Then it's also simple to define isdigit, but the standard defines it
    and doesn't leave the definition to us.
    Why isn't that the case with isodigit?
     
    JoseMariaSola, Nov 19, 2007
    #3
  4. JoseMariaSola

    Ian Collins Guest

    JoseMariaSola wrote:
    >>> The standard defines isdigit and isxdigit but doesn't say
    >>> anything about isodigit (testing for octal digits).
    >>> Anyone knows why?

    >> No, but it's simple to define, since the Standard
    >> does demand that '0'through '7' are subsequent.

    > Then it's also simple to define isdigit, but the standard defines it
    > and doesn't leave the definition to us.
    > Why isn't that the case with isodigit?
    >

    No one thought of it? You could try asking on comp.std.c

    As Richard said, it is trivial to define.

    --
    Ian Collins.
     
    Ian Collins, Nov 19, 2007
    #4
  5. JoseMariaSola

    Guest

    On Nov 19, 2:24 pm, JoseMariaSola <> wrote:
    > > > The standard defines isdigit and isxdigit but doesn't say
    > > > anything about isodigit (testing for octal digits).
    > > > Anyone knows why?

    > > No, but it's simple to define, since the Standard
    > > does demand that '0'through '7' are subsequent.

    >
    > Then it's also simple to define isdigit, but the standard defines it
    > and doesn't leave the definition to us.
    > Why isn't that the case with isodigit?



    I suspect there are two reasons. One a lack of interest, especially
    given how trivial it would be implement yourself (really? you
    actually have some a purpose for isodigit?). Second, adding another
    ctype class would probably require a bigger lookup table (assuming the
    typical design) on many small C implementations, for darn little good
    reason. If you have eight bit chars, and can live with some
    restrictions* on what different locales can do to the ctype classes,
    you can implement everything (except toupper/lower) with a single 256
    (usually 257) byte table. Add another class, and you either need 256
    shorts, or a second table.


    *Specifically, you have to disallow locales that have characters in
    isalpha that are not in islower or isupper, or with characters in
    isspace that are not in isprint or iscntrl. Which are actually a
    common conditions for compilers targeting small embedded systems,
    which often restrict themselves to just the C locale.
     
    , Nov 20, 2007
    #5
  6. JoseMariaSola

    CBFalconer Guest

    JoseMariaSola wrote:
    >
    >>> The standard defines isdigit and isxdigit but doesn't say
    >>> anything about isodigit (testing for octal digits).
    >>> Anyone knows why?

    >>
    >> No, but it's simple to define, since the Standard
    >> does demand that '0'through '7' are subsequent.

    >
    > Then it's also simple to define isdigit, but the standard
    > defines it and doesn't leave the definition to us. Why isn't
    > that the case with isodigit?


    I don't know. Why doesn't the standard library contain a routine
    to flim my diddle? I suspect the answer is the same.

    --
    Chuck F (cbfalconer at maineline dot net)
    <http://cbfalconer.home.att.net>
    Try the download section.


    --
    Posted via a free Usenet account from http://www.teranews.com
     
    CBFalconer, Nov 20, 2007
    #6
  7. JoseMariaSola

    santosh Guest

    In article
    <>,
    JoseMariaSola <> wrote on Tuesday 20 Nov 2007
    1:54 am:

    >> > The standard defines isdigit and isxdigit but doesn't say
    >> > anything about isodigit (testing for octal digits).
    >> > Anyone knows why?

    >> No, but it's simple to define, since the Standard
    >> does demand that '0'through '7' are subsequent.

    > Then it's also simple to define isdigit, but the standard defines it
    > and doesn't leave the definition to us.
    > Why isn't that the case with isodigit?


    It's trivial to implement isodigit() in terms of isdigit().
     
    santosh, Nov 20, 2007
    #7
  8. CBFalconer wrote:
    > JoseMariaSola wrote:
    >>>> The standard defines isdigit and isxdigit but doesn't say
    >>>> anything about isodigit (testing for octal digits).
    >>>> Anyone knows why?
    >>> No, but it's simple to define, since the Standard
    >>> does demand that '0'through '7' are subsequent.

    >> Then it's also simple to define isdigit, but the standard
    >> defines it and doesn't leave the definition to us. Why isn't
    >> that the case with isodigit?

    >
    > I don't know. Why doesn't the standard library contain a routine
    > to flim my diddle? I suspect the answer is the same.


    Because they didn't know what octal numbers are?
     
    Philip Potter, Nov 20, 2007
    #8
  9. JoseMariaSola

    Chris Dollin Guest

    JoseMariaSola wrote:

    >> > The standard defines isdigit and isxdigit but doesn't say
    >> > anything about isodigit (testing for octal digits).
    >> > Anyone knows why?

    >> No, but it's simple to define, since the Standard
    >> does demand that '0'through '7' are subsequent.

    > Then it's also simple to define isdigit, but the standard defines it
    > and doesn't leave the definition to us.
    > Why isn't that the case with isodigit?


    I /guess/ that when C was standardised, `isdigit` and `isxdigit` were in
    widespread use, but `isodigit` (which I can't help but read as `iso-digit`)
    wasn't.

    History: things that happened that leave traces in the present.

    --
    Chris "don't worry, coffee will fix it" Dollin

    Hewlett-Packard Limited registered office: Cain Road, Bracknell,
    registered no: 690597 England Berks RG12 1HN
     
    Chris Dollin, Nov 20, 2007
    #9
  10. JoseMariaSola

    pete Guest

    santosh wrote:
    >
    > In article
    > <>,
    > JoseMariaSola <> wrote on Tuesday 20 Nov 2007
    > 1:54 am:
    >
    > >> > The standard defines isdigit and isxdigit but doesn't say
    > >> > anything about isodigit (testing for octal digits).
    > >> > Anyone knows why?
    > >> No, but it's simple to define, since the Standard
    > >> does demand that '0'through '7' are subsequent.

    > > Then it's also simple to define isdigit, but the standard defines it
    > > and doesn't leave the definition to us.
    > > Why isn't that the case with isodigit?

    >
    > It's trivial to implement isodigit() in terms of isdigit().


    #include <ctype.h>

    int is_odigit(int c)
    {
    return isdigit(c) && '8' > c;
    }

    --
    pete
     
    pete, Nov 20, 2007
    #10
  11. In article <fhuai9$86c$>,
    Chris Dollin <> wrote:

    >I /guess/ that when C was standardised, `isdigit` and `isxdigit` were in
    >widespread use, but `isodigit` (which I can't help but read as `iso-digit`)
    >wasn't.


    It may be relevant that in early C, the digits 8 and 9 were allowed in
    octal constants.

    -- Richard
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
     
    Richard Tobin, Nov 20, 2007
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page