Checking type of a number in Julia – isinf(), isnan(), iszero() and isone() Methods
Last Updated :
26 Mar, 2020
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:
Returns: It returns true if the specified number is infinite else false.
Example:
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:
Returns: It returns true if the specified floating number is NaN else false.
Example:
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:
Returns: It returns true if the specified list of numbers are equal to or equivalent to zero else return false.
Example:
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:
Returns: It returns true if the specified numbers are equal to or equivalent to one else return false.
Example:
println(isone( 0 ))
println(isone([ 1 0 ; 0 1 ]))
println(isone( 1 ))
println(isone([false 0 ; 0 true]))
|
Output:
Share your thoughts in the comments
Please Login to comment...