Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

julia
communitycreator

How to use the isinf method in Julia

Programming Bytes

Overview

The isinf(x) method can be used to check if the given value is infinity or not.

Syntax

isinf(x) -> Bool
Julia isinf function Syntax

Argument

x: The value that is to be checked.

Return value

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

Code

The code below demonstrates how to use the isinf method.

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

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

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

Explanation

In the code above, we do the following:

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

RELATED TAGS

julia
communitycreator
RELATED COURSES

View all Courses

Keep Exploring