The method zero?
can be invoked on a float value and returns a Boolean value. It checks if the float value is 0.0
or not. If true, it returns true
. Otherwise, false
is returned.
float_value.zero?
float_value
: This is the float value we want to check to see if its value is 0.0
.
This method returns a Boolean value true
if float_value
has the value 0.0
. Otherwise, false
is returned.
# create float valuesfloat_value_one = 2.3545float_value_two = 0.0float_value_three = -0.2float_value_four = 8.9 / 8.9 * 0.0# check if 0.0puts float_value_one.zero?puts float_value_two.zero?puts float_value_three.zero?puts float_value_four.zero?
zero
method to check if the float values have the value 0.0
.