| digit-value(3scm) | Scheme Programmer's Manual | digit-value(3scm) |
NAME
digit-value - get the numeric value of a character
LIBRARY
(import (scheme char)) ;R7RS
SYNOPSIS
(digit-value char)
DESCRIPTION
This procedure returns the numeric value of its argument if it is a numeric digit or #f on any other character. Numeric digits are those for which char-numeric? returns #t. Only the numeric values 0 to 9 are supported; characters representing other values are non-numeric.
RETURN VALUES
Returns a single value; an exact integer or #f.
EXAMPLES
(digit-value #\3) => 3 (digit-value #\x0664) => 4 ;if supported (digit-value #\x0AE6) => 0 ;if supported (digit-value #\x0EA6) => #f ;if supported
COMPATIBILITY
Implementations are not required to support characters other than ASCII (excluding #\null). Therefore only the characters #\0 to #\9 need to be supported. Even implementations with full Unicode support may return #f for some characters that other implementations support, because the Unicode standard changes over time.
ERRORS
It is an error if the wrong number of arguments was passed or an argument was outside its domain. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.
SEE ALSO
string->number(3scm), char-general-category(3scm), char-numeric?(3scm)
STANDARDS
R7RS
HISTORY
This procedure first appeared in R7RS.
AUTHORS
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.
| 2023-03-21 |