Ruby Float divmod() method with example Last Updated : 14 Sep, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Float divmod() is a float class method that returns an array having the quotient and remainder on dividing two numbers. Syntax: float.divmod()Parameter: float values - dividend and divisorReturn: An array with quotient and remainder. Example #1: Ruby # Ruby code for divmod() method # Initializing value a = 4.0 b = 2.0 # Printing result puts "Division a/b : #{a.divmod(b)}\n\n" puts "Division b/a : #{b.divmod(a)}\n\n" Output : Division a/b : [2, 0.0] Division b/a : [0, 2.0] Example #2: Ruby # Ruby program for divmod() method # Initializing value a = 0 b = 2.0 # dividing by zero - gives error puts "Division a/b : #{a.divmod(b)}\n\n" puts "Division b/a : #{b.divmod(a)}\n\n" Output : source_file.rb:8:in `divmod': divided by 0 (ZeroDivisionError) from source_file.rb:8:in `' Division a/b : [0, 0.0] Comment More infoAdvertise with us Next Article Ruby Float divmod() method with example M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Float-class Similar Reads Ruby Float denominator() method with example Float#denominator() : denominator() is a float class method which return a float value as the denominator value for p/q form. Syntax: float.denominator() Parameter: float value (q) for the p/q form. [Always positive] Return: A machine-dependent result. Example #1: Ruby # Ruby code for denominator() 1 min read Ruby Float quo() method with example Float quo() is a float class method which return the quotient value of the division. Syntax: float.quo() Parameter: float values - dividend and divisor Return: Quotient value of the division. Example #1: Ruby # Ruby code for quo() method # Initializing value a = 4.0 b = 2.0 # Printing result puts 1 min read Ruby Float fdiv() method with example Float fdiv() is a float class method which return a division value of the form p/q. Syntax: float.fdiv() Parameter: values to divide - p and q Return: Division value - Quotient Example #1: Ruby # Ruby program for fdiv() method # Initializing value a = 2.0.numerator() # returning machine dependent re 1 min read Ruby Float floor() method with example floor() is a float class method which return the floor value of the passed float value. Syntax: float.floor() Parameter: float value which is to get its floor value decimal digits (default = 0) Return: smallest number >= to float with a ndigits decimal point precision. For -ve precision : Integer 1 min read Ruby Float modulo() method with example Float modulo() is a float class method which return the remainder value on dividing two float values. Syntax: float.modulo() Parameter: remainder value from the operation p/q Return: Modulo i.e. Remainder Example #1: Example for modulo() method Ruby # Ruby program for modulo() method # Initilizig va 1 min read Like