Ruby Float negative() method with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report Float negative() is a float class method which checks whether the float value is negative. Syntax: float.negative() Parameter: float value which is to be checked Return: Boolean value return false - if value is positive and return true - if value is negative Example #1: Ruby # Ruby code for negative() method # Initializing value a = -100.7 - 10.4 b = -100 * 2000.0 c = (22 + 7.1) * 4 # Printing result puts "a is negative : #{a.negative?}\n\n" puts "b is negative : #{b.negative?}\n\n" puts "c is negative : #{c.negative?}\n\n" Output : a is negative : true b is negative : true c is negative : false Example #2: Ruby # Ruby code for negative() method # Initializing value a = -56.23333333 b = 10000.0 c = -(22 + 7.1) # Printing Result puts "a is negative : #{a.negative?}\n\n" puts "b is negative : #{b.negative?}\n\n" puts "c is negative : #{c.negative?}\n\n" Output : a is negative : true b is negative : false c is negative : true Comment More infoAdvertise with us Next Article Ruby Float negative() method with example M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Float-class Similar Reads Ruby Float positive() method with example Float positive() is a float class method which checks whether the float value is positive. Syntax: float.positive() Parameter: float value which is to be checked Return: Boolean value return true - if value is positive or return false - if value is negative Example #1:Â Ruby # Ruby program for posit 1 min read Ruby Float nan?() method with example Float nan?() is a float class method that checks whether the value is 'not a number'. 'Not A Number' means an invalid IEEE floating-point number. Syntax: float.nan?()Parameter: float value to be passedReturn: Return true - if the value is 'not a number' otherwise return false Example #1:Â Â Ruby # Ru 1 min read Ruby Float phase() method with example Float phase() is a float class method which works on float values and works differently for both positive and negative values. Syntax: float.phase() Parameter: float value which is to be checked Return: return 0 for positive values otherwise return pi(3.141592653589793) Example #1: Ruby # Ruby code 1 min read Ruby Float arg() method with example Float arg() is a float class method which works on float values and works differently for both positive and negative values. Syntax: float.arg() Parameter: float value which is to be checked Return: return 0 for positive values. Otherwise pi(3.141592653589793) Example #1: Ruby # Ruby code for arg() 1 min read Ruby Float zero?() method with example Float#zero() : zero() is a float class method which checks whether the float value is zero. Syntax: float.zero() Parameter:float value which is to be checked Return: Boolean value return true if value is zero otherwise return false Example #1: Ruby # Ruby code for zero?() method # Initializing value 1 min read Like