GeeksforGeeks App
Open App
Browser
Continue

# Checking type of a number in Julia – isinf(), isnan(), iszero() and isone() Methods

The `isinf()` is an inbuilt function in julia which is used to test whether the specified number is infinite or not.

Syntax: isinf(x)

Parameters:

• x: Specified values.

Returns: It returns true if the specified number is infinite else false.

Example:

 `# Julia program to illustrate ``# the use of isinf() method`` ` `# Getting true if the specified``# number is infinite else false.``println(isinf(``0``))``println(isinf(``0` `/` `0``))``println(isinf(``1` `/` `0``))``println(isinf(``0` `/` `1``))`

Output:

```false
false
true
false
```

#### isnan()

The `isnan()` is an inbuilt function in julia which is used to test whether the specified floating point number is not a number (NaN).

Syntax: isnan(x)

Parameters:

• x: Specified values.

Returns: It returns true if the specified floating number is NaN else false.

Example:

 `# Julia program to illustrate ``# the use of isnan() method`` ` `# Getting true if the specified``# floating number is NaN else false.``println(isnan(``0``))``println(isnan(``0` `/` `0``))``println(isnan(``1` `/` `0``))``println(isnan(``0` `/` `1``))`

Output:

```false
true
false
false
```

#### iszero()

The `iszero()` is an inbuilt function in julia which is used to return true if the specified list of numbers are equal to or equivalent to zero else return false.

Syntax: iszero(x)

Parameters:

• x: Specified values.

Returns: It returns true if the specified list of numbers are equal to or equivalent to zero else return false.

Example:

 `# Julia program to illustrate ``# the use of iszero() method`` ` `# Getting true if the specified ``# list of numbers are equal to ``# or equivalent to zero else false.``println(iszero(``0``))``println(iszero([``1``, ``0``]))``println(iszero([false, ``0``, ``0.0``]))``println(iszero([false, ``2``, ``0``]))`

Output:

```true
false
true
false
```

#### isone()

The `isone()` is an inbuilt function in julia which is used to return true if the specified numbers are equal to or equivalent to one else return false. Here identity matrix is also used as parameter.

Syntax: isone(x)

Parameters:

• x: Specified values.

Returns: It returns true if the specified numbers are equal to or equivalent to one else return false.

Example:

 `# Julia program to illustrate ``# the use of isone() method`` ` `# Getting true if the specified ``# numbers are equal to or equivalent``# to one else return false.``println(isone(``0``))``println(isone([``1` `0``; ``0` `1``]))``println(isone(``1``))``println(isone([false ``0``; ``0` `true]))`

Output:

My Personal Notes arrow_drop_up