:: SHARE THIS POST ::
Checked and Unchecked operators in C# Step By Step
In this article we will understand use of or working with Checked and Unchecked operators in C# Step By Step using example ....Click To Know More
Remember Top 3 important points of out and ref in C#
3 important points to remember while working with out and ref in C# ....Click To Know More
Install SQL Server 2014 Step by Step with example
In this article learn to install SQL Server 2014 step by step using our example image screen shots without any errors ....Click To Know More
Type Safe in C#.NET step by step using example
Here in this article let's understand Type Safe in CSharp.NET step by step with an example ....Click To Know More
App Domain in C#.NET Step by Step using example
In this article let's understand about app domain in csharp(C#).NET step by step using simple example. ....Click To Know More
Delay signing in C# with example
In this article athesham sir talks about delay signing and discuss Delay signing definition in more detail ....Click To Know More
Tuples in c# example step by step
In this Part 1 of the article we learn about Tuples which is not new to programming languages but it was new to C# when introduced in C# 4.0. We will see ....Click To Know More
C# Anonymous Types vs Tuples with an example
This article is the continuation of previous part 1 in which we had earlier seen how tuples reduces the code by making it more tidy and readable ....Click To Know More
Anonymous Methods in C# with an example Step by Step
This article written by "Ahtesham Shaikh" in this article understand Anonymous Methods in C# with an example Step by Step ....Click To Know More
In a statement or expression if one the operand is real (float) and another one is integer then expression is called as Mixed Mode Arithmetic Expression. If in an expression either operand is of real then output is always in real format. If both operands are real then output will be in real formats.
Real operand and Integer operand = Real operand (Output)
Real operand and Real operand = Real operand (Output).
"*" - Multiply use for Multiplication
"/" - Divide use for division
"+" - Plus use for addition
"-" - Minus use for subtraction
"%" - Modulus use for getting a reminder
"**" - Square use for getting square number
Evaluate Expressions always from Left to Right
For Example: 3 + 5 - 4 = 4
Priority of an operator is also considered while calculating an expression
Operator Priorities in descending order
1. (**) Known as Square operator which executes From Right To Left .
For example 5**2 is equal to 25
2. (*) Known as multiplication operator which executes From Left to Right
For example 5 * 2 is equal to 10
3. (/) Known as Division operator which executes From Left to Right
For example 6 / 2 is equal to 3
4. (+) Known as Plus or Addition operator which executes From Left to Right
For example 6 + 2 is equal to 8
5. (-) Known as Minus or Subtraction operator which executes From Left to Right
For example 6 - 2 is equal to 4
Mixed mode operator example
2 + 2 * 5 ** 3
==> 2 + 2 * (5**3)
==> 2 + 2 * 125
==> 2 + (2 * 125)
==> 2 + 250 = 252
If the operands of this operator are of the same type means either Integer or Real, compute the same for result in that operator only.
Both Real Numbers
double a = 2.0;
double b = 3.0;
Double add = 2.0 + 3.0 = 5.0 (Result in Real Number only)
Both Integer Number
int a = 2;
int b = 3;
int add = 2 + 3 = 5 (Result in Integer Number only)
If one of the operator is Integer and other one is real then convert integer number to real number and compute the result in real number only.
double a = 5.0;
int b = 5;
Result = 5.0 = 5 = 10.0 (Result in Real Number only).
So this all about evaluating mixed mode arithmetic expression. Let me know your thoughts while working on mixed mode arithmetic expression. Kindly post your comments.
More C# Articles To Read Next:
What is an event handler and explain how it is designed ?
Views - 6285 |Category - C#
Is C# is Modern, Type Safe, Versionable and Inter operability Language ?
Views - 9916 |Category - C#
Discuss Boxing and Unboxing in the context of value types and reference types
Views - 7401 |Category - C#
Understanding Switch Statement with the help of an example
Views - 5141 |Category - C#
Checked and Unchecked operators using an example
Views - 5843 |Category - C#
All fields marked with * are mandatory