• Share Ideas, Start Something Good.

### Scala – Data types and operators

• date 30th September, 2020 |
• by Prwatech |

## Guide to Data Types in Scala

### Data Types

1. Byte: It is an 8 bit signed value.

2. Short: It is a 16 bit signed value.

3. Int: It is a 32 bit signed value.

4. Long: It is a 64 bit signed value.

5. Float: It can store 32 bit of data

6. Double: It can store 64 bit of data

7. Char: It is a 16 bit unsigned Unicode character.

8. String: It is a sequence of Chars

9. Boolean: It holds either of these values the literal true or the literal false

10. Null: It holds empty reference or null

12. Nothing: It is the subtype of every other data type which includes no values

13. Any: It is the super type of any type where any object is of type Any

14. AnyRef: It is the super type of any reference type No.

### Operators

An operator is a symbol that instructs the compiler to perform any mathematical or logical manipulations. Scala is rich in built-in operators and different types of operators are:

1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Bitwise Operators
5. Assignment Operators

#### Arithmetic Operators

The following are the arithmetic operators supported by Scala language.

For example, if variables A=6 and B=16, then

#### Relational Operators

The following are the relational operators supported by Scala language.

For example, if variables A=6 and B=16, then

#### Logical Operators

The following logical operators are supported by Scala language.

For example, if variables b1=true and b2=false, then

Prog1. Define 1 to natural numbers and sum them.

Prog2. Define 50 numbers which should start from 0 and find out only odd numbers. Then multiply all odd numbers with 2 and sum all of them.