isinf

isinf(f) -> Bool

Test whether a number is infinite

Examples

  1. Check if a number is infinite:

    julia> isinf(5.0)
    false

    This example checks if the number 5.0 is infinite. Since 5.0 is not infinite, it returns false.

  2. 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 returns true as -Inf is indeed infinite.

  3. 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. The isinf function correctly identifies it as infinite and returns true.

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.

*Required Field
Details

Checking you are not a robot: