In Julia, the isinteger(x)
method checks whether or not the given value is equal to an integer.
The syntax of the method is given below:
isinteger(x) -> Bool
x
: This is the value that is to be checked.
This method returns true
if the provided value is numerically equal to an integer value. Otherwise, it returns false
.
The code below demonstrates the use of the isinteger
method:
## find isinteger of 3.0 println( "isinteger(3.0) => $(isinteger(3.0))") ## find isinteger of 10 println( "isinteger(10) => $(isinteger(10))") ## find isinteger of 3.5 println( "isinteger(3.5) => $(isinteger(3.5))")
Line 2: We use the isinteger
method with 3.0
as an argument. The isinteger(3.0)
returns true
.
Line 5: We use the isinteger
method with 10
as an argument. The isinteger(10)
returns true
.
Line 8: We use the isinteger
method with 3.5
as an argument. The isinteger(3.5)
returns false
because 3.5
is not an integer value.
RELATED TAGS
CONTRIBUTOR
View all Courses