Articles

Arithmetic Operators in Java

by Julia Lopez Student
Java is Sun Microsoft's programming language developed in the mid-1990s. Java was developed by James A. Gosling, a former Sun Microsoft computer scientist. He’s known as Father of Java. The market has undergone an evolutionary change with the introduction of Java on the market. The language and is features have been strong enough to block the whole market and to make any software popular written in it. Platform independence and object-faced features make Java extremely popular with others. Java is a programming language that is overwhelmingly accepted all over the world. The language is known for its ease of use and usability. The language contains different helping methods which make it easy to use.

Java supports the use of operators, as with other programming languages. Operators are an important part of Java. The word operator originated in the late 1500s from the Latin language. This comes from the word "opera" that has the meaning of the work. An operator is generally a person who performs some operation. In a programming language such as Java, operators are the special symbols used to express a certain type of operation. These particular characters are just like a function. These operations or calculations are carried out on either constants or values. These operations can be performed on two values, two variables or even on a value and variable combination. The value of the action is called an operand and the operation is defined by the operator. Operators in Java are further divided into many subtypes. This division is carried forward on the basis of the operators' functionality.

In Java, operators are further divided into the following types of operators: Arithmetic, Logical, Arithmetic  Assignment, Relational, Conditional, Shift. Arithmetic operators are the most famous types of operators in Java. The term arithmetic is defined by the Greek word " arithmos, " meaning number. This is based on the word " arithmetic in Latin When these two words are combined, the meaning is quite pretty obvious-the operations on numbers. Arithmetic operators are special symbols used to carry out certain numerical calculations and operations. They come second according to the Java operators preferences list. These operators are used to perform basic mathematical calculations on numbers just like subtraction (-), addition (+), division (/) and multiplication (*). Apart from these four basic mathematical operations, these operators can also be used to calculate the number modulus (%). When modulus is used, it essentially works with the remainder of the number.

Int a + int b = Int c
2 – 1 = int d
Int d * 2 = int e
Int e / 1 = int f
Int g= int f % 2

These operators are also used to increase and decrease the value by one place. These arithmetic operators are called as increment and decrement operator. By using the double plus (++), the number can be increased by one value and similarly with the help of (--), one can decrease the value of a number by one place. The positioning of these increment and decrement operator is really very vitally important. If this operator is placed before the operand, then it becomes the pre-increment. If
the operator is after the operand, then it is known as post-decrement.

In postfix notation, the value of the operand is evaluated before the increment while in prefix mathematical expression, evaluation of the value of the operand is performed after the increment operation. This same rule is followed while performing a subtraction operation.

Post-increment: a++
Pre-increment: ++a
Post-decrement: a—
Pre-decrement: --a

The operators work on mathematical expressions. Depending on the expression, there can be a change in the position of the operand or the operator. Operators can take up three places i.e. infix, postfix, and prefix positions. The most common position for any operator is infix position where the operator lies between two operands. In prefix notation, the operator is in the front of the operands and in postfix position, the operator takes up the last place after the operands.

Java also supports different arity for its operators. Arity is the number of operands in one mathematical operation. It supports unary, binary and ternary operators. These different arities are also part of different operator groups. For example, if we take the example of an arithmetic operator, it may have one or two operands in the same mathematical expression on which the calculation has to be performed. Unary operations are performed with a single operator and single operand. The binary operation needs a minimum of two operands. Arithmetic operators can be performed in both the ways. Unary minus (-) denotes a negative value in the mathematical expression. Unary plus (+) is the operator which is used to indicate the positive value.

The results of the operators also depend on their working precedence. Few operators work from right to left and few operators operate from left to right. Arithmetic operators operate from left to right. This means that the first operand from the left-hand side is stored in the memory first, followed up by the other operands and operators in the mathematical expression.

By far now, we have seen all the basic operators that fall under the category of arithmetic operators. These are basically used for mathematical calculations. Though every operator demands for a specific data type input, each operator also gives the value in that specific data type. The arithmetic operator returns a float value if any one of the operands possesses the quality of float data type. They return double if one of the operands is of double type. Long value is given as output if any operand belongs to the long family. However, arithmetic operators return int if the operator type is smaller than the size of it.

To sum up, Arithmetic operators are the basic operators of Java which are used to perform certain mathematical operations on numbers. These operators can be either unary or binary. They work on the precedence from left to right.

About Us

Doing Arithmetic assignments is not at all an easy or simple piece of academic task. It requires knowledge and research skills. You can hire EssayCorp to grab the best online Arithmetic Assignment help at an affordable price with on-time delivery.

Sponsor Ads


About Julia Lopez Advanced   Student

143 connections, 4 recommendations, 471 honor points.
Joined APSense since, December 17th, 2018, From Alaska, United States.

Created on Jan 20th 2019 04:32. Viewed 440 times.

Comments

No comment, be the first to comment.
Please sign in before you comment.