Ruby | Rational quo() function Last Updated : 19 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The quo() is an inbuilt function in Ruby returns the rational number by performing division. Syntax: rat1.quo(rat2) Parameters: The function accepts a single parameter Return Value: It returns the rational number by performing division Example 1: Ruby # Ruby program for quo() method # Initialize rational number rat1 = Rational(-2, 9) rat2 = Rational(-9, 2) # Prints the rational number puts rat1.quo(rat2) Output: 4/81 Example 2: Ruby # Ruby program for quo() method # Initialize rational number rat1 = Rational(-2, 9) # Prints the rational number puts rat1.quo(2.5) Output: -0.08888888888888888 Comment More infoAdvertise with us Next Article Ruby | Rational quo() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Rational-class Similar Reads Ruby | Rational to_r() function The to_r() is an inbuilt function in Ruby returns it's own value Syntax: rat.to_r() Parameters: The function accepts no parameter Return Value: It returns it's own value Example 1: CPP #Ruby program for to_r() method #Initialize rational number rat1 = Rational(18, -4) #Prints the rational number put 1 min read Ruby | Rational to_i() function The to_i() is an inbuilt function in Ruby returns the truncated integer value Syntax: rat.to_i() Parameters: The function accepts no parameter Return Value: It returns the truncated integer value Example 1: CPP #Ruby program for to_i() method #Initialize rational number rat1 = Rational(9, -2) #Print 1 min read Ruby | Rational numerator() function The numerator() is an inbuilt function in Ruby returns the numerator. Syntax: rat.numerator() Parameters: The function accepts no parameter Return Value: It returns the numerator Example 1: Ruby # Ruby program for numerator() method # Initialize rational number rat1 = Rational(7, -3) # Prints the ra 1 min read Ruby | Rational <=> function The <=> is an inbuilt method in Ruby returns -1, 0, or +1 depending on whether rational is less than, equal to, or greater than the numeric value. nil is returned if the two values are incomparable. Syntax: rat1<=>rat2 Parameters: The function accepts no parameter Return Value: It return 1 min read Ruby | Rational abs() function The abs() is an inbuilt function in Ruby returns the absolute value of rational. Syntax: rational.abs() Parameters: The function accepts no parameter Return Value: It returns returns the absolute value of rational. Example 1: Ruby # Ruby program for abs() method # Initialize rational number rat1 = R 1 min read Like