# digittoint(3) [osx man page]

```DIGITTOINT(3)						   BSD Library Functions Manual 					     DIGITTOINT(3)

NAME
digittoint, digittoint_l -- convert a numeric character to its integer value

LIBRARY
Standard C Library (libc, -lc)

SYNOPSIS
#include <ctype.h>

int
digittoint(int c);

#include <xlocale.h>
#include <ctype.h>

int
digittoint_l(int c, locale_t loc);

DESCRIPTION
The digittoint() function converts a numeric character to its corresponding integer value.  The character can be any decimal digit or hexa-
decimal digit.  With hexadecimal characters, the case of the values does not matter.

While the digittoint() function uses the current locale, the digittoint_l() function may be passed a locale directly. See xlocale(3) for more
information.

RETURN VALUES
The digittoint() function always returns an integer from the range of 0 to 15.  If the given character was not a digit as defined by
isxdigit(3), the function will return 0.

ctype(3), isdigit(3), isxdigit(3), xlocale(3)

BSD								   April 6, 2001							       BSD```

## Check Out this Related Man Page

```CTYPE_L(3)						   BSD Library Functions Manual 						CTYPE_L(3)

NAME
digittoint_l, isalnum_l, isalpha_l, isascii_l, isblank_l, iscntrl_l, isdigit_l, isgraph_l, ishexnumber_l, isideogram_l, islower_l,
isnumber_l, isphonogram_l, isprint_l, ispunct_l, isrune_l, isspace_l, isspecial_l, isupper_l, isxdigit_l, tolower_l, toupper_l -- character
classification functions

LIBRARY
Standard C Library (libc, -lc)

SYNOPSIS
#include <ctype.h>

int
digittoint_l(int c, locale_t loc);

int
isalnum_l(int c, locale_t loc);

int
isalpha_l(int c, locale_t loc);

int
isascii_l(int c, locale_t loc);

int
iscntrl_l(int c, locale_t loc);

int
isdigit_l(int c, locale_t loc);

int
isgraph_l(int c, locale_t loc);

int
ishexnumber_l(int c, locale_t loc);

int
isideogram_l(int c, locale_t loc);

int
islower_l(int c, locale_t loc);

int
isnumber_l(int c, locale_t loc);

int
isphonogram_l(int c, locale_t loc);

int
isspecial_l(int c, locale_t loc);

int
isprint_l(int c, locale_t loc);

int
ispunct_l(int c, locale_t loc);

int
isrune_l(int c, locale_t loc);

int
isspace_l(int c, locale_t loc);

int
isupper_l(int c, locale_t loc);

int
isxdigit_l(int c, locale_t loc);

int
tolower_l(int c, locale_t loc);

int
toupper_l(int c, locale_t loc);

DESCRIPTION
The above functions perform character tests and conversions on the integer c in the locale loc.  They behave in the same way as the versions
without the _l suffix, but use the specified locale rather than the global or per-thread locale.  <ctype.h>, or as true functions in the C

digittoint(3), isalnum(3), isalpha(3), isascii(3), isblank(3), iscntrl(3), isdigit(3), isgraph(3), isideogram(3), islower(3), isphonogram(3),
isprint(3), ispunct(3), isrune(3), isspace(3), isspecial(3), isupper(3), isxdigit(3), tolower(3), toupper(3), wctype(3), xlocale(3)

STANDARDS
These functions conform to IEEE Std 1003.1-2008 (``POSIX.1''), except for digittoint_l(), isascii_l(), ishexnumber_l(), isideogram_l(),
isnumber_l(), isphonogram_l(), isrune_l() and isspecial_l() which are FreeBSD extensions.

BSD								   March 6, 2012							       BSD```
Man Page

## How to convert a 2 digit to 4 digit

Hi All, How can i convert a number 24 to 0024 In the same way how can i convert 123 to 0123? All this has to be done inside a script Thanks in advance JS

## check whether it is a non-numeric character

Below is the abstract of the script which is working fine. if ] then error_process "Invalid month format." return 1 fi I am doing validation for month and it errors if the value is > 12 or < 0. In addition, I want to add another condition to error if it...

## Prefix integer with zeros

I want an integer to be prefix with some zeros so that it makes the integer 5 digit always: For eg: if the digit is 8 i need 00008 if the digit is 8976 ans sud be 08976. Could anyone say simple and efficient commands to this in ksh. Thanks a lot...

## how to grep only particular length of numeric values

hi i have two types of file 1. temp.0000000001.data (10 digit numeric) 2. temp.000000001.data (9 digit numeric) i want to search a file which is having 10 digit numeric in between the file name. i use command like this.. ls | grep temp.^*.data but this will give both the files as...

## compare decimal and integer values in if in bash shell

i need to do camparisions like the below. For the case when first=10 and second=9.9 the scripts displays process failed. I need to be able to convert the values to integer before doing the comparision. Like 9.9 should be rounded over to 10 before doing comparision. Please advice how can...

## To convert file with decimal to another file with Hexadecimal

I have a text file of alphanumeric values listed one by one. I have to convert them to hexadecimal equivalents for each character seperated by ":" in Unix bash shell script. For example, 12345678 has to be converted to 31:32:33:34:35:36:37:38

## Awk numeric range match only one digit?

Hello, I have a text file with lines that look like this: 1974 12 27 -0.72743 -1.0169 2 1.25029 1974 12 28 -0.4958 -0.72926 2 0.881839 1974 12 29 -0.26331 -0.53426 2 0.595623 1974 12 30 7.71432E-02 -0.71887 3 0.723001 1974 12 31 0.187789 -1.07114 3 1.08748 1975 1 1 0.349933 -1.02217...

## Replacing string length based on pattern

Hi All, I have a file which is like below. I need to read all the patterns that starts with P and then replace the 9 digit values to 8 digit values (remove leading integer). Can you please help Example : ( Please look below File) File : P,1 M1,...