isinf
isinf(f) -> Bool
Test whether a number is infinite
Examples
-
Check if a number is infinite:
julia> isinf(5.0) false
This example checks if the number
5.0
is infinite. Since5.0
is not infinite, it returnsfalse
. -
Determine if a negative number is infinite:
julia> isinf(-Inf) true
Here, the function
isinf
is used to check if the negative infinity value-Inf
is considered infinite. It returnstrue
as-Inf
is indeed infinite. -
Check if a positive value is infinite:
julia> isinf(1.0 / 0.0) true
In this example, the expression
1.0 / 0.0
is evaluated, which results in a positive infinity value. Theisinf
function correctly identifies it as infinite and returnstrue
.
Common mistake example:
julia> isinf("hello")
ERROR: MethodError: no method matching isinf(::String)
In this example, the isinf
function is applied to a string "hello"
. However, isinf
is meant to check for infinity in numbers, not strings. Ensure that the argument provided to isinf
is a valid numeric value to avoid such errors.
See Also
all, all!, angle, any, any!, falses, ifelse, is, isinf, isinteger, isnan, isperm, ispow2, isreal, trues,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.