Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > isodigit

Reply
Thread Tools

isodigit

 
 
JoseMariaSola
Guest
Posts: n/a
 
      11-19-2007
The standard defines isdigit and isxdigit but doesn't say anything
about isodigit (testing for octal digits).
Anyone knows why?
Thanks.
Joey.
 
Reply With Quote
 
 
 
 
Richard Bos
Guest
Posts: n/a
 
      11-19-2007
JoseMariaSola <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
JoseMariaSola
Guest
Posts: n/a
 
      11-19-2007
> > 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?

 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      11-19-2007
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.
 
Reply With Quote
 
robertwessel2@yahoo.com
Guest
Posts: n/a
 
      11-20-2007
On Nov 19, 2:24 pm, JoseMariaSola <(E-Mail Removed)> 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.
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      11-20-2007
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

 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      11-20-2007
In article
<(E-Mail Removed)>,
JoseMariaSola <(E-Mail Removed)> 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().

 
Reply With Quote
 
Philip Potter
Guest
Posts: n/a
 
      11-20-2007
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?
 
Reply With Quote
 
Chris Dollin
Guest
Posts: n/a
 
      11-20-2007
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

 
Reply With Quote
 
pete
Guest
Posts: n/a
 
      11-20-2007
santosh wrote:
>
> In article
> <(E-Mail Removed)>,
> JoseMariaSola <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments