Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

julia
communitycreator

How to use the isfinite method in Julia

Programming Bytes

Overview

The isfinite() method can be used to check if the given value is a finite number or not.

Syntax

isfinite(f) -> Bool
Julia isfinite function Syntax

Parameter

This method takes the parameter f which represents the value that is to be checked.

Return value

This method returns true if the provided value is finite. Otherwise, false is returned.

Code

The code below demonstrates how to use the isfinite method.

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

## find isfinite of 10
println( "isfinite(10) => $(isfinite(10))")

## find isfinite of 0
println( "isfinite(0) => $(isfinite(0))")
Using the isfinite method

Explanation

In the code above, we do the following:

  • Line 2: We use the isfinite method with (10/0) as an argument. Any non-zero value divided by 0 will produce an infinite value. So the isfinite(10/0) will return false.
  • Line 5: We use the isfinite method with 10 as an argument. The isfinite(10)will return true because 10 is a finite value.
  • Line 8: We use the isfinite method with 0 as an argument. The isfinite(0)will return true because 0 is a finite value.

RELATED TAGS

julia
communitycreator
RELATED COURSES

View all Courses

Keep Exploring