Ruby Language Numbers Dividing two numbers

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

When dividing two numbers pay attention to the type you want in return. Note that dividing two integers will invoke the integer division. If your goal is to run the float division, at least one of the parameters should be of float type.

Integer division:

3 / 2 # => 1

Float division

3 / 3.0 # => 1.0

16 / 2 / 2    # => 4
16 / 2 / 2.0  # => 4.0
16 / 2.0 / 2  # => 4.0
16.0 / 2 / 2  # => 4.0


Got any Ruby Language Question?