Determines whether the string contains decimal characters

## Usage

The `isdecimal()` method returns TRUE if the string is nonempty and all characters in it are decimal characters. Otherwise, it returns FALSE.

Decimal characters are those that can be used to form numbers in base 10 (0-9).

Unicode decimal character such as U+0660 (Arabic-Indic Digit Zero) is also considered as a decimal.

## Syntax

string.isdecimal()

## Basic Examples

Example: Check if all characters in the string are decimal characters

``````S = '123'
x = S.isdecimal()
print(x)    # True``````

Below are a few examples where `isdecimal()` method returns false.

Example:

``````# floating point number
S = '123.456'
x = S.isdecimal()
print(x)    # False``````
``````# number with thousands separator
S = '1,234,567'
x = S.isdecimal()
print(x)    # False``````
``````# empty string
S = ''
x = S.isdecimal()
print(x)    # False``````

## isdecimal() on Unicode Decimal Characters

Unicode character such as U+0660 (Arabic-Indic Digit Zero) is also considered as a decimal.

Example:

``````S = '\u0660'
x = S.isdigit()
print(x)    # True``````

## isdecimal() vs isdigit() vs isnumeric()

Following examples explain the difference between the three methods.

Example: Is 42 a decimal or digit or numeric number?

``print('42'.isdecimal())		# True``
``print('42'.isdigit())		# True``
``print('42'.isnumeric())		# True``

Example: Is ² (Superscript Two) a decimal or digit or numeric number?

``print('\u00b2'.isdecimal())		# False``
``print('\u00b2'.isdigit())		# True``
``print('\u00b2'.isnumeric())		# True``

Example: Is ⅓ (Vulgar Fraction One Third) a decimal or digit or numeric number?

``print('\u2153'.isdecimal())		# False``
``print('\u2153'.isdigit())		# False``
``print('\u2153'.isnumeric())		# True``

As you can see, the main difference between the three functions is:

• isdecimal() method supports only Decimal Numbers.
• isdigit() method supports Decimals, Subscripts, Superscripts.
• isnumeric() method supports Digits, Vulgar Fractions, Subscripts, Superscripts, Roman Numerals, Currency Numerators.