[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] digit-value

Peter Bex scripsit:

> Alternatively, change it to accept just the ASCII number characters,
> and possibly with Marc's suggestion of accepting digits in any base
> (and perhaps an optional second argument to specify which base we're
>  working in).  That would really be useful, since that could be used
> to implement very common char->number conversion and could even be
> used internally in string->number (at least conceptually).

It's quite common (though technically not portable) to determine that a
character is a digit using `char-numeric?` and then determine its value
using `(- (char->integer x) (char->integer #\0))` or the equivalent.
Because the WG decided that `char-numeric?` returns `#t` on all decimal
digits (but not other numeric characters), providing a method of
determining the value seemed a Good Thing.

Where the wombat has walked,            John Cowan <cowan@x>
it will inevitably walk again.          http://www.ccil.org/~cowan
   (even through brick walls!)

Scheme-reports mailing list