# What is Scala – Operators ? Types of Opertors in Scala

If you are interested to learn about the Scala Modifires

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Scala is rich in built-in operators and provides the following types of operators −

• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators

This chapter will examine the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

## Arithmetic Operators

The following arithmetic operators are supported by Scala language. For example, let us assume variable A holds 10 and variable B holds 20, then −

## Relational Operators

The following relational operators are supported by Scala language. For example let us assume variable A holds 10 and variable B holds 20, then −

## Logical Operators

The following logical operators are supported by Scala language. For example, assume variable A holds 1 and variable B holds 0, then −

## Bitwise Operators

Bitwise operator works on bits and perform bit by bit operation. The truth tables for &, |, and ^ are as follows −

Assume if A = 60; and B = 13; now in binary format they will be as follows −

``````A = 0011 1100
B = 0000 1101
-----------------------
A&B = 0000 1100
A|B = 0011 1101
A^B = 0011 0001
~A = 1100 0011
``````

The Bitwise operators supported by Scala language is listed in the following table. Assume variable A holds 60 and variable B holds 13, then −

## Assignment Operators

There are following assignment operators supported by Scala language −

Show Examples

## Operators Precedence in Scala

Operator precedence determines the grouping of terms in an expression. This affects how an expression is evaluated. Certain operators have higher precedence than others; for example, the multiplication operator has higher precedence than the addition operator −

For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has higher precedence than +, so it first gets multiplied with 3*2 and then adds into 7.

Take a look at the following table. Operators with the highest precedence appear at the top of the table and those with the lowest precedence appear at the bottom. Within an expression, higher precedence operators will be evaluated first.

What is Scala – Operators ? Types of Opertors in Scala