VOOZH about

URL: https://www.geeksforgeeks.org/ruby/ruby-float-divmod-method-with-example/

⇱ Ruby Float divmod() method with example - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Ruby Float divmod() method with example

Last Updated : 14 Sep, 2021

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 divisor
Return: An array with quotient and remainder.

Example #1: 

Output : 

Division a/b : [2, 0.0]

Division b/a : [0, 2.0]

Example #2:  

Output : 

source_file.rb:8:in `divmod': divided by 0 (ZeroDivisionError)
 from source_file.rb:8:in `'

Division a/b : [0, 0.0]


 

Comment
Article Tags: