Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

isnan
julia
communitycreator

How to use the isnan() method in Julia?

Programming Bytes

Overview

The isnan(x) method checks whether or not the given value is NaNNot a Number.

Syntax

isnan(f) -> Bool
The Julia isnan function

Argument(s)

x: This is the value that is to be checked.

Return value

This method returns true if the provided value is NaN. Otherwise, it returns false.

Code

The code below demonstrates the use of the isnan() method:

## find isnan of 0 / 0
println( "isnan(0 / 0) => $(isnan(0 / 0))")

## find isnan of NaN
println( "isnan(NaN) => $(isnan(NaN))")

## find isnan of 10
println( "isnan(10) => $(isnan(10))")
Using the isnan method

Explanation

  • Line 2: We use the isnan() method with (0/0) as an argument. Dividing zero by 0 produces a NaN value. Therefore, the isnan(0/0) returns true.
  • Line 5: We use the isnan() method with NaN as an argument. The isnan(NaN) returns true .
  • Line 8: We use the isnan() method with 10 as an argument. The isnan(10) returns false because 10 is a finite value and not a NaN value.

RELATED TAGS

isnan
julia
communitycreator
RELATED COURSES

View all Courses

Keep Exploring