The isnan(x)
method checks whether or not the given value is
isnan(f) -> Bool
x
: This is the value that is to be checked.
This method returns true
if the provided value is NaN
. Otherwise, it returns false
.
The code below demonstrates the use of the isnan()
method:
## find isnan of 0 / 0println( "isnan(0 / 0) => $(isnan(0 / 0))")## find isnan of NaNprintln( "isnan(NaN) => $(isnan(NaN))")## find isnan of 10println( "isnan(10) => $(isnan(10))")
isnan()
method with (0/0)
as an argument. Dividing zero by 0
produces a NaN
value. Therefore, the isnan(0/0)
returns true
.isnan()
method with NaN
as an argument. The isnan(NaN)
returns true
.isnan()
method with 10
as an argument. The isnan(10)
returns false
because 10
is a finite value and not a NaN
value.