# digittoint_l(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

```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```
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

## 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,...