---
title: "Ruby Arithmetic Operators Tutorial"
url: https://weworkworldwide.com/tutorials/ruby-arithmetic-operators-tutorial/
description: "In this section we will learn what the Arithmetic Operators are and how to use them in Ruby. Note: in this section we’re assuming you’re familiar with the"
date: 2026-05-12T14:32:25+00:00
source: https://weworkworldwide.com/llms.txt
---

# Ruby Arithmetic Operators Tutorial

In this section we will learn what the Arithmetic Operators are and how to use them in Ruby.

Note: in this section we’re assuming you’re familiar with *the Ruby operators in general.*

## What is Arithmetic Operator in Ruby?

In Ruby those operators that are used to run mathematical operations, are called Arithmetic Operators.

For example, the multiplication operator is used for multiplying values to each other, division operator is used for dividing one value to another, addition operator is used for adding two values together, etc.

## Arithmetic Operators List in Ruby

In the table below you can see the list of arithmetic operators supported in Ruby.

[TABLE]

## Ruby Addition `+` Operator:

The addition operator with the symbol `+` is used to add to values to each other and return the result.

## Addition `+` Operator Syntax:

``` line-numbers
left_operand + right_operand
```

## Example: using addition `+` operator in Ruby

``` line-numbers
res = 10 + 20
puts res
Output:
30
```

## Ruby Subtraction `-` Operator:

The subtraction operator with the symbol `-` is used to subtract one value from another and return the result.

## Subtraction `-` Operator Syntax:

``` line-numbers
left_operand - right_operand
```

## Example: using subtraction `-` operator in Ruby

``` line-numbers
val1 = 10
val2 = 5
res = val1 – val2
puts res
Output:
5
```

## Ruby Multiplication `*` Operator:

The multiplication operator with the symbol `*` is used to multiply two values to each other and return the result.

## Multiplication `*` Operator Syntax:

``` line-numbers
left_operand * right_operand
```

## Example: using multiplication `*` operator in Ruby

``` line-numbers
val1 = 10
val2 = 5
res = val1 * val2
puts res
Output:
50
```

## Ruby Division `/` Operator:

The division operator with the symbol `/` is used to divide the left_operand by the right_operand and return the result.

## Division `/` Operator Syntax:

``` line-numbers
left_operand / right_operand
```

## Example: using division operator in Ruby

``` line-numbers
val1 = 10
val2 = 5
res = val1 / val2
puts res
Output:
2
```

## Division with Ruby Fixnum data type value

Note that when dividing two whole numbers (of type Fixnum) by each other, the result will become a Fixnum! That means even if the result has decimal numbers in it, it will be stripped away and only the whole number part of the result returns instead.

So if we want to get the decimal part as well, one of the involved operands must become of type float then.

One of the easiest way to convert a Fixnum type to Float is by calling the `to_f` method on the target integer value.

## Example: using fixnum values in division operation

``` line-numbers
val1 = 10.to_f
val2 = 3
res = val1 / val2
puts res
Output:
3.3333333333333335
```

In the last example if we remove the `to_f` method and divide the two values by each other, the result will be only the value 3.

## Ruby Modulus `%` Operator:

The modulus operator with the symbol `%` is used to find the remainder value (whole number) when dividing one value by another one.

## Modulus `%` Operator Syntax:

``` line-numbers
left_operand % right_operand
```

## Example: using modulus operator in Ruby

``` line-numbers
val1 = 14
val2 = 3
res = val1 % val2
puts res
Output:
2
```

## Ruby Exponent `**` Operator:

The exponent operator with the symbol `**` is used to run exponential (power) operation on the operands involved.

## Exponent `**` Operator Syntax:

``` line-numbers
left_operand ** right_operand
```

## Example: using exponent operator in Ruby

``` line-numbers
val1 = 2
val2 = 3
res = val1 ** val2
puts res
Output:
8
```
