This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Assignment operators (C# reference)

  • 11 contributors

The assignment operator = assigns the value of its right-hand operand to a variable, a property , or an indexer element given by its left-hand operand. The result of an assignment expression is the value assigned to the left-hand operand. The type of the right-hand operand must be the same as the type of the left-hand operand or implicitly convertible to it.

The assignment operator = is right-associative, that is, an expression of the form

is evaluated as

The following example demonstrates the usage of the assignment operator with a local variable, a property, and an indexer element as its left-hand operand:

The left-hand operand of an assignment receives the value of the right-hand operand. When the operands are of value types , assignment copies the contents of the right-hand operand. When the operands are of reference types , assignment copies the reference to the object.

This is called value assignment : the value is assigned.

ref assignment

Ref assignment = ref makes its left-hand operand an alias to the right-hand operand, as the following example demonstrates:

In the preceding example, the local reference variable arrayElement is initialized as an alias to the first array element. Then, it's ref reassigned to refer to the last array element. As it's an alias, when you update its value with an ordinary assignment operator = , the corresponding array element is also updated.

The left-hand operand of ref assignment can be a local reference variable , a ref field , and a ref , out , or in method parameter. Both operands must be of the same type.

Compound assignment

For a binary operator op , a compound assignment expression of the form

is equivalent to

except that x is only evaluated once.

Compound assignment is supported by arithmetic , Boolean logical , and bitwise logical and shift operators.

Null-coalescing assignment

You can use the null-coalescing assignment operator ??= to assign the value of its right-hand operand to its left-hand operand only if the left-hand operand evaluates to null . For more information, see the ?? and ??= operators article.

Operator overloadability

A user-defined type can't overload the assignment operator. However, a user-defined type can define an implicit conversion to another type. That way, the value of a user-defined type can be assigned to a variable, a property, or an indexer element of another type. For more information, see User-defined conversion operators .

A user-defined type can't explicitly overload a compound assignment operator. However, if a user-defined type overloads a binary operator op , the op= operator, if it exists, is also implicitly overloaded.

C# language specification

For more information, see the Assignment operators section of the C# language specification .

  • C# operators and expressions
  • ref keyword
  • Use compound assignment (style rules IDE0054 and IDE0074)

Additional resources

  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Staging Ground badges

Earn badges by improving or asking questions in Staging Ground.

IDE0059 Unnecessary assignment of a value to 'i'

This code produces in Visual Studio 2019 Information Message: *Severity Code Description Project File Line Suppression State Suppression State Detail Description Message IDE0059

Unnecessary assignment of a value to 'i'

Avoid unnecessary value assignments in your code, as these likely indicate redundant value computations. If the value computation is not redundant and you intend to retain the assignment, then change the assignment target to a local variable whose name starts with an underscore and is optionally followed by an integer, such as '_', '_1', '_2', etc. These are treated as special discard symbol names.*

The code snippet works OK, it's the message IDE0059, what bothers me. I don't want to suppress it, if is possible.

Whats wrong here? Is it false positive or I miss something?

This code also produces warning IDE0059 in VS2019:

  • visual-studio-2019

Christopher Klein's user avatar

  • it seems to be moaning because unless there is an error, i is never used. –  BugFinder Commented Nov 15, 2019 at 7:42
  • What do you expect to happen once i is 0 and you get another exception? –  Herohtar Commented Nov 15, 2019 at 7:42
  • replace the when with an if statement in the catch... The while loop is not necessary, since you are returning the first succesfully loaded file. i think it would be easier to just use a for() loop. –  Glenn van Acker Commented Nov 15, 2019 at 7:43
  • The reason you're getting that warning is because it's a false positive. The compiler is probably ignoring the i in the catch statement. that's why it's better to just use a for loop, and remove the i from the catch statement. you can still let the thread sleep in that catch statement. –  Glenn van Acker Commented Nov 15, 2019 at 7:50
  • I want only catch IOExceptions when i>0, all other exceptions schuld be throwen –  Ive Commented Nov 15, 2019 at 7:50

2 Answers 2

According to your description, it seems that you want to end the sleep when you go through

two exceptions without throwing the warning.

I suggest that you can use if sentence to do it.

Jack J Jun- MSFT's user avatar

  • I don't have problem with code, it's seems to work OK what I know, but that visual studio produces this message IDE0059 bothers me. I don't want only suppress it, I want to make it right –  Ive Commented Nov 18, 2019 at 7:15
  • I don't have that warning, so please check it again. –  Jack J Jun- MSFT Commented Nov 18, 2019 at 7:38
  • This code does not produces IOException when i == 0, i need to throw Exception when i == 0. –  Ive Commented Nov 20, 2019 at 7:58
  • I have updated my code, you could have a look to see if it can solve your problem. –  Jack J Jun- MSFT Commented Nov 21, 2019 at 1:57
  • 1 @Ive Don't do throw ex as it will reset your call stack . Your original code was OK. I wouldn't refactor my code just to please a bugged compiler. I'm having a similar issue and applying VS recommended changes breaks my code. –  Juan Commented Feb 22, 2020 at 17:07

Message IDE0059 is indicating the assignment of "int i = 2;" is unnecessary. To save the computation, use "int i;". With i now starting at the default of zero (0) and decreasing with "i--;", also change the comparisons to "(i > -2)" and "(i == -2)" per the code examples.

Rocco's user avatar

  • 1 i is a local variable, so it must be explicitly assigned to before being used, or else there is a compiler error. It does not default to 0. –  Joe Sewell Commented Jan 22, 2020 at 20:17
  • Bunch of warnings for this and it is so annoying. I can add a suppression file entry for each file, but I can't find the warning to turn this off. I don't want any suggestions for my code. I want it to compile, or not compile. –  user12228709 Commented Jul 7, 2020 at 22:22

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged c# visual-studio-2019 or ask your own question .

  • The Overflow Blog
  • Brain Drain: David vs Goliath
  • How API security is evolving for the GenAI era
  • Featured on Meta
  • Preventing unauthorized automated access to the network
  • Upcoming initiatives on Stack Overflow and across the Stack Exchange network...
  • Proposed designs to update the homepage for logged-in users

Hot Network Questions

  • Are Vcc and Vin the same thing for logic gates?
  • acknowledgments in publications
  • Ban user IP address by HTTP request?
  • Ideas how to make slides easily
  • Arrange the 15 dominoes so that the sum of the fractions in each row is 10
  • Can you find the Mate in 1?
  • Can you make all the squares the same color?
  • When might it *not* be a good idea to reset your password immediately?
  • How long would it have taken to travel from Southhampton to Madeira by boat in the 1920s?
  • Need to replace special character "/" with another string
  • Why helicopters don't use complete tail rotor guard?
  • How to deal with overtaking personal space and decision making?
  • "Criminals" are put in isolated prison cells until they "die," but they actually get a new personality instead
  • Is entropy scale-invariant?
  • OLS linear regression of +/-1 standard deviation and not the mean
  • Disable memory swap / compression on a single process
  • My previous advisor wrote that I'm not creative in his recommendation letter
  • I rely too much on counting beats, how can I improve?
  • How do I make reimbursements easier on my students?
  • Pomp and circumstance march no. 1 Edward Elgar F horn and trumpet written without key signature - which C was it transposed to?
  • Is it possible to have multiple class action lawsuits for the same problem?
  • Analysis of methods to ensure memory safety
  • Convert French spelled out numbers to integers
  • Is the word "retard" really spoken when some planes land?

was the assignment of value to you

  • Skip to main content
  • Skip to search
  • Skip to select language
  • Sign up for free
  • Remember language

Assignment (=)

Baseline widely available.

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015 .

  • See full compatibility
  • Report feedback

The assignment ( = ) operator is used to assign a value to a variable or property. The assignment expression itself has a value, which is the assigned value. This allows multiple assignments to be chained in order to assign a single value to multiple variables.

A valid assignment target, including an identifier or a property accessor . It can also be a destructuring assignment pattern .

An expression specifying the value to be assigned to x .

Return value

The value of y .

Thrown in strict mode if assigning to an identifier that is not declared in the scope.

Thrown in strict mode if assigning to a property that is not modifiable .

Description

The assignment operator is completely different from the equals ( = ) sign used as syntactic separators in other locations, which include:

  • Initializers of var , let , and const declarations
  • Default values of destructuring
  • Default parameters
  • Initializers of class fields

All these places accept an assignment expression on the right-hand side of the = , so if you have multiple equals signs chained together:

This is equivalent to:

Which means y must be a pre-existing variable, and x is a newly declared const variable. y is assigned the value 5 , and x is initialized with the value of the y = 5 expression, which is also 5 . If y is not a pre-existing variable, a global variable y is implicitly created in non-strict mode , or a ReferenceError is thrown in strict mode. To declare two variables within the same declaration, use:

Simple assignment and chaining

Value of assignment expressions.

The assignment expression itself evaluates to the value of the right-hand side, so you can log the value and assign to a variable at the same time.

Unqualified identifier assignment

The global object sits at the top of the scope chain. When attempting to resolve a name to a value, the scope chain is searched. This means that properties on the global object are conveniently visible from every scope, without having to qualify the names with globalThis. or window. or global. .

Because the global object has a String property ( Object.hasOwn(globalThis, "String") ), you can use the following code:

So the global object will ultimately be searched for unqualified identifiers. You don't have to type globalThis.String ; you can just type the unqualified String . To make this feature more conceptually consistent, assignment to unqualified identifiers will assume you want to create a property with that name on the global object (with globalThis. omitted), if there is no variable of the same name declared in the scope chain.

In strict mode , assignment to an unqualified identifier in strict mode will result in a ReferenceError , to avoid the accidental creation of properties on the global object.

Note that the implication of the above is that, contrary to popular misinformation, JavaScript does not have implicit or undeclared variables. It just conflates the global object with the global scope and allows omitting the global object qualifier during property creation.

Assignment with destructuring

The left-hand side of can also be an assignment pattern. This allows assigning to multiple variables at once.

For more information, see Destructuring assignment .

Specifications

Specification

Browser compatibility

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

  • Assignment operators in the JS guide
  • Destructuring assignment

was the assignment of value to you

  • Table of Contents
  • Course Home
  • Assignments
  • Peer Instruction (Instructor)
  • Peer Instruction (Student)
  • Change Course
  • Instructor's Page
  • Progress Page
  • Edit Profile
  • Change Password
  • Scratch ActiveCode
  • Scratch Activecode
  • Instructors Guide
  • About Runestone
  • Report A Problem
  • 1.1 Getting Started
  • 1.1.1 Preface
  • 1.1.2 About the AP CSA Exam
  • 1.1.3 Transitioning from AP CSP to AP CSA
  • 1.1.4 Java Development Environments
  • 1.1.5 Growth Mindset and Pair Programming
  • 1.1.6 Pretest for the AP CSA Exam
  • 1.1.7 Survey
  • 1.2 Why Programming? Why Java?
  • 1.3 Variables and Data Types
  • 1.4 Expressions and Assignment Statements
  • 1.5 Compound Assignment Operators
  • 1.6 Casting and Ranges of Values
  • 1.7 Unit 1 Summary
  • 1.8 Mixed Up Code Practice
  • 1.9 Toggle Mixed Up or Write Code Practice
  • 1.10 Coding Practice
  • 1.11 Multiple Choice Exercises
  • 1.12 Method Signatures (preview 2026 curriculum)
  • 1.13 Calling Class Methods (preview 2026 curriculum)
  • 1.3. Variables and Data Types" data-toggle="tooltip">
  • 1.5. Compound Assignment Operators' data-toggle="tooltip" >

Before you keep reading...

Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.

Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.

Time estimate: 90 min.

1.4. Expressions and Assignment Statements ¶

In this lesson, you will learn about assignment statements and expressions that contain math operators and variables.

1.4.1. Assignment Statements ¶

Assignment statements initialize or change the value stored in a variable using the assignment operator = . An assignment statement always has a single variable on the left hand side. The value of the expression (which can contain math operators and other variables) on the right of the = sign is stored in the variable on the left.

../_images/assignment.png

Figure 1: Assignment Statement (variable = expression;) ¶

Instead of saying equals for the = in an assignment statement, say “gets” or “is assigned” to remember that the variable gets or is assigned the value on the right. In the figure above score is assigned the value of the expression 10 times points (which is another variable) plus 5.

The following video by Dr. Colleen Lewis shows how variables can change values in memory using assignment statements.

As we saw in the video, we can set one variable’s value to a copy of the value of another variable like y = x; . This won’t change the value of the variable that you are copying from.

Let’s step through the following code in the Java visualizer to see the values in memory. Click on the Next button at the bottom of the code to see how the values of the variables change. You can run the visualizer on any Active Code in this e-book by just clicking on the Code Lens button at the top of each Active Code.

Activity: CodeLens 1.4.1.2 (asgnviz1)

exercise

1-4-3: What are the values of x, y, and z after the following code executes? You can step through this code by clicking on this Java visualizer link.

  • x = 0, y = 1, z = 2
  • These are the initial values in the variable, but the values are changed.
  • x = 1, y = 2, z = 3
  • x changes to y's initial value, y's value is doubled, and z is set to 3
  • x = 2, y = 2, z = 3
  • Remember that the equal sign doesn't mean that the two sides are equal. It sets the value for the variable on the left to the value from evaluating the right side.
  • x = 0, y = 0, z = 3

The following has the correct code to ‘swap’ the values in x and y (so that x ends up with y’s initial value and y ends up with x’s initial value), but the code is mixed up and contains one extra block which is not needed in a correct solution. Drag the needed blocks from the left into the correct order on the right. Check your solution by clicking on the Check button. You will be told if any of the blocks are in the wrong order or if you need to remove one or more blocks. After three incorrect attempts you will be able to use the Help Me button to make the problem easier.

1.4.2. Adding 1 to a Variable ¶

If you use a variable to keep score, you would probably increment it (add one to the current value) whenever score should go up. You can do this by setting the variable to the current value of the variable plus one ( score = score + 1 ) as shown below. The formula would look strange in math class, but it makes sense in coding because it is assigning a new value to the variable on the left that comes from evaluating the arithmetic expression on the right. So, the score variable is set to the previous value of score plus 1.

Try the code below to see how score is incremented by 1. Try substituting 2 instead of 1 to see what happens.

1.4.3. Input with Variables ¶

Variables are a powerful abstraction in programming because the same algorithm can be used with different input values saved in variables. The code below using the Scanner class will say hello to anyone who types in their name and will have different results for different name values. First, type in your name below the code and then click on run. Try again with a friend’s name. The code works for any name: behold, the power of variables!

The code below will say hello to anyone who types in their name. Type in your name below the code and then click on run. Try again with a friend’s name.

Although you will not be tested in the AP CSA exam on using the Java input or the Scanner or Console classes, learning how to do input in Java is very useful and fun. For more information on using the Scanner class, go to https://www.w3schools.com/java/java_user_input.asp , and for the newer Console class, https://howtodoinjava.com/java-examples/console-input-output/ . We are limited with the one way communication with the Java server in this Runestone ebook, but in most IDEs, the input/output would be more interactive. You can try this Scanner input example in JuiceMind (click on Create Starter Code after login with a Google account) or Scanner input example in Replit using the Scanner class and Console input example using the Console class.

1.4.4. Operators ¶

Java uses the standard mathematical operators for addition ( + ), subtraction ( - ), and division ( / ). The multiplication operator is written as * , as it is in most programming languages, since the character sets used until relatively recently didn’t have a character for a real multiplication sign, × , and keyboards still don’t have a key for it. Likewise no ÷ .

You may be used to using ^ for exponentiation, either from a graphing calculator or tools like Desmos. Confusingly ^ is an operator in Java, but it has a completely different meaning than exponentiation and isn’t even exactly an arithmetic operator. You will learn how to use the Math.pow method to do exponents in Unit 2.

Arithmetic expressions can be of type int or double . An arithmetic expression consisting only of int values will evaluate to an int value. An arithmetic expression that uses at least one double value will evaluate to a double value. (You may have noticed that + was also used to combine String and other values into new String s. More on this when we talk about String s more fully in Unit 2.)

Java uses the operator == to test if the value on the left is equal to the value on the right and != to test if two items are not equal. Don’t get one equal sign = confused with two equal signs == . They mean very different things in Java. One equal sign is used to assign a value to a variable. Two equal signs are used to test a variable to see if it is a certain value and that returns true or false as you’ll see below. Also note that using == and != with double values can produce surprising results. Because double values are only an approximation of the real numbers even things that should be mathematically equivalent might not be represented by the exactly same double value and thus will not be == . To see this for yourself, write a line of code below to print the value of the expression 0.3 == 0.1 + 0.2 ; it will be false !

coding exercise

Run the code below to see all the operators in action. Do all of those operators do what you expected? What about 2 / 3? Isn’t it surprising that it prints 0? See the note below about truncating division with integers. Change the code to make it print the decimal part of the division too. You can do this by making at least one of the numbers a double like 2.0.

When Java sees you doing integer division (or any operation with integers) it assumes you want an integer result so it throws away anything after the decimal point in the answer. This is called truncating division . If you need a double answer, you should make at least one of the values in the expression a double like 2.0.

With division, another thing to watch out for is dividing by 0. An attempt to divide an integer by zero will result in an ArithmeticException error message. Try it in one of the active code windows above.

Operators can be used to create compound expressions with more than one operator. You can either use a literal value which is a fixed value like 2, or variables in them. When compound expressions are evaluated, operator precedence rules are used, just like when we do math (remember PEMDAS?), so that * , / , and % are done before + and - . However, anything in parentheses is done first. It doesn’t hurt to put in extra parentheses if you are unsure as to what will be done first or just to make it more clear.

In the example below, try to guess what it will print out and then run it to see if you are right. Remember to consider operator precedence . How do the parentheses change the precedence?

1.4.5. The Remainder Operator ¶

The operator % in Java is the remainder operator. Like the other arithmetic operators is takes two operands. Mathematically it returns the remainder after dividing the first number by the second, using truncating integer division. For instance, 5 % 2 evaluates to 1 since 2 goes into 5 two times with a remainder of 1.

While you may not have heard of remainder as an operator, think back to elementary school math. Remember when you first learned long division, before they taught you about decimals, how when you did a long division that didn’t divide evenly, you gave the answer as the number of even divisions and the remainder. That remainder is what is returned by this operator. In the figures below, the remainders are the same values that would be returned by 2 % 3 and 5 % 2 .

../_images/mod-py.png

Figure 1: Long division showing the integer result and the remainder ¶

Sometimes people—including Professor Lewis in the next video—will call % the modulo , or mod , operator. That is not actually correct though the difference between remainder and modulo, which uses Euclidean division instead of truncating integer division, only matters when negative operands are involved and the signs of the operands differ. With positive operands, remainder and mod give the same results. Java does have a method Math.floorMod in the Math class if you need to use modulo instead of remainder, but % is all you need in the AP exam.

Here’s the video .

In the example below, try to guess what it will print out and then run it to see if you are right.

The result of x % y when x is smaller than y is always x. The value y can’t go into x at all (goes in 0 times), since x is smaller than y, so the result is just x. So if you see 2 % 3 the result is 2.

1-4-11: What is the result of 158 % 10?

  • This would be the result of 158 divided by 10. % gives you the remainder.
  • % gives you the remainder after the division.
  • When you divide 158 by 10 you get a remainder of 8.

1-4-12: What is the result of 3 % 8?

  • 8 goes into 3 no times so the remainder is 3. The remainder of a smaller number divided by a larger number is always the smaller number!
  • This would be the remainder if the question was 8 % 3 but here we are asking for the reminder after we divide 3 by 8.
  • What is the remainder after you divide 3 by 8?

1.4.6. Programming Challenge : Dog Years ¶

dog

In this programming challenge, you will calculate your age, and your pet’s age from your birthdates, and your pet’s age in dog years. In the code below, type in the current year, the year you were born, the year your dog or cat was born (if you don’t have one, make one up!) in the variables below. Then write formulas in assignment statements to calculate how old you are, how old your dog or cat is, and how old they are in dog years which is 7 times a human year. Finally, print it all out. If you are pair programming, switch drivers (who has control of the keyboard in pair programming) after every line of code.

Calculate your age and your pet’s age from the birthdates, and then your pet’s age in dog years.

Your teacher may suggest that you use a Java IDE like replit.com for this challenge so that you can use input to get these values using the Scanner class . Here is a repl template that you can use to get started if you want to try the challenge with input.

1.4.7. Summary ¶

Arithmetic expressions include expressions of type int and double .

The arithmetic operators consist of + , - , * , / , and % also known as addition, subtraction, multiplication, division, and remainder.

An arithmetic operation that uses two int values will evaluate to an int value. With integer division, any decimal part in the result will be thrown away.

An arithmetic operation that uses at least one double value will evaluate to a double value.

Operators can be used to construct compound expressions.

During evaluation, operands are associated with operators according to operator precedence to determine how they are grouped. ( * , / , % have precedence over + and - , unless parentheses are used to group those.)

An attempt to divide an integer by zero will result in an ArithmeticException .

The assignment operator ( = ) allows a program to initialize or change the value stored in a variable. The value of the expression on the right is stored in the variable on the left.

During execution, expressions are evaluated to produce a single value.

The value of an expression has a type based on the types of the values and operators used in the expression.

1.4.8. AP Practice ¶

The following is a 2019 AP CSA sample question.

1-4-14: Consider the following code segment.

What is printed when the code segment is executed?

  • 0.666666666666667
  • Don't forget that division and multiplication will be done first due to operator precedence.
  • Yes, this is equivalent to (5 + ((a/b)*c) - 1).
  • Don't forget that division and multiplication will be done first due to operator precedence, and that an int/int gives an int truncated result where everything to the right of the decimal point is dropped.
  • Language Reference

Assignment Operators

The basic assignment operator is "=". Your first inclination might be to think of this as "equal to". Don't. It really means that the left operand gets set to the value of the expression on the right (that is, "gets set to").

The value of an assignment expression is the value assigned. That is, the value of " $a = 3 " is 3. This allows you to do some tricky things: <?php $a = ( $b = 4 ) + 5 ; // $a is equal to 9 now, and $b has been set to 4. ?>

In addition to the basic assignment operator, there are "combined operators" for all of the binary arithmetic , array union and string operators that allow you to use a value in an expression and then set its value to the result of that expression. For example: <?php $a = 3 ; $a += 5 ; // sets $a to 8, as if we had said: $a = $a + 5; $b = "Hello " ; $b .= "There!" ; // sets $b to "Hello There!", just like $b = $b . "There!"; ?>

Note that the assignment copies the original variable to the new one (assignment by value), so changes to one will not affect the other. This may also have relevance if you need to copy something like a large array inside a tight loop.

An exception to the usual assignment by value behaviour within PHP occurs with object s, which are assigned by reference. Objects may be explicitly copied via the clone keyword.

Assignment by Reference

Assignment by reference is also supported, using the " $var = &$othervar; " syntax. Assignment by reference means that both variables end up pointing at the same data, and nothing is copied anywhere.

Example #1 Assigning by reference

The new operator returns a reference automatically, as such assigning the result of new by reference is an error.

The above example will output:

More information on references and their potential uses can be found in the References Explained section of the manual.

Arithmetic Assignment Operators

Example Equivalent Operation
$a += $b $a = $a + $b Addition
$a -= $b $a = $a - $b Subtraction
$a *= $b $a = $a * $b Multiplication
$a /= $b $a = $a / $b Division
$a %= $b $a = $a % $b Modulus
$a **= $b $a = $a ** $b Exponentiation

Bitwise Assignment Operators

Example Equivalent Operation
$a &= $b $a = $a & $b Bitwise And
$a |= $b $a = $a | $b Bitwise Or
$a ^= $b $a = $a ^ $b Bitwise Xor
$a <<= $b $a = $a << $b Left Shift
$a >>= $b $a = $a >> $b Right Shift

Other Assignment Operators

Example Equivalent Operation
$a .= $b $a = $a . $b String Concatenation
$a ??= $b $a = $a ?? $b Null Coalesce
  • arithmetic operators
  • bitwise operators
  • null coalescing operator

Improve This Page

User contributed notes 4 notes.

To Top

1.4 — Variable assignment and initialization

  • Python Basics
  • Interview Questions
  • Python Quiz
  • Popular Packages
  • Python Projects
  • Practice Python
  • AI With Python
  • Learn Python3
  • Python Automation
  • Python Web Dev
  • DSA with Python
  • Python OOPs
  • Dictionaries

Assignment Operators in Python

The Python Operators are used to perform operations on values and variables. These are the special symbols that carry out arithmetic, logical, and bitwise computations. The value the operator operates on is known as the Operand. Here, we will cover Different Assignment operators in Python .

Operators

=

Assign the value of the right side of the expression to the left side operandc = a + b 


+=

Add right side operand with left side operand and then assign the result to left operanda += b   

-=

Subtract right side operand from left side operand and then assign the result to left operanda -= b  


*=

Multiply right operand with left operand and then assign the result to the left operanda *= b     


/=

Divide left operand with right operand and then assign the result to the left operanda /= b


%=

Divides the left operand with the right operand and then assign the remainder to the left operanda %= b  


//=

Divide left operand with right operand and then assign the value(floor) to left operanda //= b   


**=

Calculate exponent(raise power) value using operands and then assign the result to left operanda **= b     


&=

Performs Bitwise AND on operands and assign the result to left operanda &= b   


|=

Performs Bitwise OR on operands and assign the value to left operanda |= b    


^=

Performs Bitwise XOR on operands and assign the value to left operanda ^= b    


>>=

Performs Bitwise right shift on operands and assign the result to left operanda >>= b     


<<=

Performs Bitwise left shift on operands and assign the result to left operanda <<= b 


:=

Assign a value to a variable within an expression

a := exp

Here are the Assignment Operators in Python with examples.

Assignment Operator

Assignment Operators are used to assign values to variables. This operator is used to assign the value of the right side of the expression to the left side operand.

Addition Assignment Operator

The Addition Assignment Operator is used to add the right-hand side operand with the left-hand side operand and then assigning the result to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the addition assignment operator which will first perform the addition operation and then assign the result to the variable on the left-hand side.

S ubtraction Assignment Operator

The Subtraction Assignment Operator is used to subtract the right-hand side operand from the left-hand side operand and then assigning the result to the left-hand side operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the subtraction assignment operator which will first perform the subtraction operation and then assign the result to the variable on the left-hand side.

M ultiplication Assignment Operator

The Multiplication Assignment Operator is used to multiply the right-hand side operand with the left-hand side operand and then assigning the result to the left-hand side operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the multiplication assignment operator which will first perform the multiplication operation and then assign the result to the variable on the left-hand side.

D ivision Assignment Operator

The Division Assignment Operator is used to divide the left-hand side operand with the right-hand side operand and then assigning the result to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the division assignment operator which will first perform the division operation and then assign the result to the variable on the left-hand side.

M odulus Assignment Operator

The Modulus Assignment Operator is used to take the modulus, that is, it first divides the operands and then takes the remainder and assigns it to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the modulus assignment operator which will first perform the modulus operation and then assign the result to the variable on the left-hand side.

F loor Division Assignment Operator

The Floor Division Assignment Operator is used to divide the left operand with the right operand and then assigs the result(floor value) to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the floor division assignment operator which will first perform the floor division operation and then assign the result to the variable on the left-hand side.

Exponentiation Assignment Operator

The Exponentiation Assignment Operator is used to calculate the exponent(raise power) value using operands and then assigning the result to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the exponentiation assignment operator which will first perform exponent operation and then assign the result to the variable on the left-hand side.

Bitwise AND Assignment Operator

The Bitwise AND Assignment Operator is used to perform Bitwise AND operation on both operands and then assigning the result to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the bitwise AND assignment operator which will first perform Bitwise AND operation and then assign the result to the variable on the left-hand side.

Bitwise OR Assignment Operator

The Bitwise OR Assignment Operator is used to perform Bitwise OR operation on the operands and then assigning result to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the bitwise OR assignment operator which will first perform bitwise OR operation and then assign the result to the variable on the left-hand side.

Bitwise XOR Assignment Operator 

The Bitwise XOR Assignment Operator is used to perform Bitwise XOR operation on the operands and then assigning result to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the bitwise XOR assignment operator which will first perform bitwise XOR operation and then assign the result to the variable on the left-hand side.

Bitwise Right Shift Assignment Operator

The Bitwise Right Shift Assignment Operator is used to perform Bitwise Right Shift Operation on the operands and then assign result to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the bitwise right shift assignment operator which will first perform bitwise right shift operation and then assign the result to the variable on the left-hand side.

Bitwise Left Shift Assignment Operator

The Bitwise Left Shift Assignment Operator is used to perform Bitwise Left Shift Opertator on the operands and then assign result to the left operand.

Example: In this code we have two variables ‘a’ and ‘b’ and assigned them with some integer value. Then we have used the bitwise left shift assignment operator which will first perform bitwise left shift operation and then assign the result to the variable on the left-hand side.

Walrus Operator

The Walrus Operator in Python is a new assignment operator which is introduced in Python version 3.8 and higher. This operator is used to assign a value to a variable within an expression.

Example: In this code, we have a Python list of integers. We have used Python Walrus assignment operator within the Python while loop . The operator will solve the expression on the right-hand side and assign the value to the left-hand side operand ‘x’ and then execute the remaining code.

Assignment Operators in Python – FAQs

What are assignment operators in python.

Assignment operators in Python are used to assign values to variables. These operators can also perform additional operations during the assignment. The basic assignment operator is = , which simply assigns the value of the right-hand operand to the left-hand operand. Other common assignment operators include += , -= , *= , /= , %= , and more, which perform an operation on the variable and then assign the result back to the variable.

What is the := Operator in Python?

The := operator, introduced in Python 3.8, is known as the “walrus operator”. It is an assignment expression, which means that it assigns values to variables as part of a larger expression. Its main benefit is that it allows you to assign values to variables within expressions, including within conditions of loops and if statements, thereby reducing the need for additional lines of code. Here’s an example: # Example of using the walrus operator in a while loop while (n := int(input("Enter a number (0 to stop): "))) != 0: print(f"You entered: {n}") This loop continues to prompt the user for input and immediately uses that input in both the condition check and the loop body.

What is the Assignment Operator in Structure?

In programming languages that use structures (like C or C++), the assignment operator = is used to copy values from one structure variable to another. Each member of the structure is copied from the source structure to the destination structure. Python, however, does not have a built-in concept of ‘structures’ as in C or C++; instead, similar functionality is achieved through classes or dictionaries.

What is the Assignment Operator in Python Dictionary?

In Python dictionaries, the assignment operator = is used to assign a new key-value pair to the dictionary or update the value of an existing key. Here’s how you might use it: my_dict = {} # Create an empty dictionary my_dict['key1'] = 'value1' # Assign a new key-value pair my_dict['key1'] = 'updated value' # Update the value of an existing key print(my_dict) # Output: {'key1': 'updated value'}

What is += and -= in Python?

The += and -= operators in Python are compound assignment operators. += adds the right-hand operand to the left-hand operand and assigns the result to the left-hand operand. Conversely, -= subtracts the right-hand operand from the left-hand operand and assigns the result to the left-hand operand. Here are examples of both: # Example of using += a = 5 a += 3 # Equivalent to a = a + 3 print(a) # Output: 8 # Example of using -= b = 10 b -= 4 # Equivalent to b = b - 4 print(b) # Output: 6 These operators make code more concise and are commonly used in loops and iterative data processing.

author

Similar Reads

  • Python-Operators

Please Login to comment...

  • Free Music Recording Software in 2024: Top Picks for Windows, Mac, and Linux
  • Best Free Music Maker Software in 2024
  • What is Quantum AI? The Future of Computing and Artificial Intelligence Explained
  • Noel Tata: Ratan Tata's Brother Named as a new Chairman of Tata Trusts
  • GeeksforGeeks Practice - Leading Online Coding Platform

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Why does the assignment operator assign to the left-hand side?

I began teaching a friend programming just recently (we're using Python), and when we began discussing variable creation and the assignment operator, she asked why the value on the right is assigned to the name on the left, and not vice-versa.

I had not thought about it too much before, because it seemed natural to me, but she said that left-to-right seemed more natural to her, since that's how most of us read natural languages.

I thought about it, and concluded that it makes code much easier to read, since the names that are assigned to (which the programmer will need to reuse) are easily visible, aligned on the left.

As opposed to:

Now I wonder if there are other reasons as well for this standard. Is there a history behind it? Or is there some technical reason why this is a good option (I don't know much about compilers)? And are there any programming languages that assign to the right side?

  • language-design

voithos's user avatar

  • 15 R can assign to the right-hand side ( value -> variable ). –  You Commented Aug 3, 2011 at 22:06
  • 21 Is your friend's name... Yoda? –  Adriano Carneiro Commented Aug 4, 2011 at 16:36
  • 1 Reminds me of if (3 == i) to avoid the =/== typo –  BlackJack Commented Aug 4, 2011 at 20:28
  • 1 If she starts compaining about this, I wonder what will she do when she sees C++ & co. –  BlackBear Commented Aug 4, 2011 at 21:55
  • 3 Just a side note: Khan Academy has some lessons on Python for beginner programmers: khanacademy.org/#computer-science and Google has some for more advanced: code.google.com/edu/languages/google-python-class/set-up.html –  lindon fox Commented Aug 9, 2011 at 2:54

13 Answers 13

Ditto @paxdiablo. The early programming languages were written by mathematicians--actually all of them were. In mathematics, by her own principle--reading left to right-- it makes sense in the way it works.

x = 2y - 4.

In mathematics, you would say this: Let x be equal to 2y -4.

Also, even in algebra you do this. When you solve an equation for a variable, you isolate the variable you are solving for to the left side. i.e. y = mx + b;

Furthermore, once an entire family of languages-- such as the C family-- has a certain syntax, it is more costly to change.

surfasb's user avatar

  • 20 @FarmBoy: in mathematics, assignment and equality ARE the same thing, as there is no sequence in a formula as there is in computers. ( a equals b and at the same time b equals a ) –  Petruza Commented Aug 4, 2011 at 3:17
  • 1 @FB except in some single assignment functional languages like e.g. Erlang. Assignment and Assuring equality are the same like in mathematics –  Peer Stritzinger Commented Aug 4, 2011 at 6:00
  • 20 @Petruza No, in mathematics assignment and equality are not the same thing. If I say 'Let x = 2y - 3' it is different from 'Thus x = 2y - 3'. I math, typically context differentiates them. Since The comment disputing me was so universally acclaimed, I'll mention that I do have a Ph.D. in mathematics, I'm pretty sure about this. –  Eric Wilson Commented Aug 4, 2011 at 12:32
  • 2 I don't know mathematics anywhere near a PhD, what I state is that as there is no sequentiality, there's no order of execution in mathematics both in an assignment or in an equality, unlike programming, in which both sides of an assignment can be different at some point in time, and they end up being equal at some other point in time. But in mathematics, in an assignment like let a be... as there is no time, both sides of the assignment are equal as well, so the assignment is in fact an equality, no wonder why both use the same sign: = –  Petruza Commented Aug 4, 2011 at 18:47
  • 5 @Petruzza - but there is sequentiality. Mathematical documents are written from start to end, the same as any other document. If I assert x = 1 in chapter one, but assert x = 2 in chapter two, that isn't some terrible contradiction - each assertion applies only within a certain context. The difference in imperative programming is partly the removal of a barrier (we don't need a change of context), and partly about implementation and usefulness. –  user8709 Commented Aug 5, 2011 at 8:27

BASIC , one of the earliest computer languages had the "proper" form of:

which matches the mathematical mindset of specifying a variable, like "Let H be the height of the object".

COBOL was also similar with its COMPUTE statement. As with many ways of doing things, it may have simply been an arbitrary decision that was carried forward through many languages.

  • 7 I suppose that this form is more natural when program lines are considered as "statements" as opposed to "operations." As in, I declare that X must equal THIS , instead of the more linear Evaluate THIS and store it in X –  voithos Commented Aug 3, 2011 at 22:26
  • Wait, BASIC was an 'early' computer language? –  Alex Feinman Commented Aug 4, 2011 at 18:12
  • 2 @Alex Considering that it harkens from the 1960s, I'd say that's pretty early. –  Ben Richards Commented Aug 4, 2011 at 21:32
  • 1 On the other hand, in COBOL you could write MULTIPLY HEIGHT BY WIDTH GIVING AREA , so the variable that gets the result is on the very right side of the statement. –  user281377 Commented Aug 5, 2011 at 9:14

Actually, there is a programming language that assigns to the right side: TI-BASIC ! Not just that, but it also doesn't use '=' as the assignment operator, but rather uses an arrow known as the "STO" operator.

In the above example, three variables are being declared and given values. A would be 5, B would be 8, and C would be -3. The first declaration/assignment can be read 'store 5 as A'.

As to why TI-BASIC uses such a system for assignment, I attribute it to being because it is a programming language for a calculator. The "STO" operator on TI calculators was most often used in normal calculator operations after a number was calculated. If it was a number the user wanted to remember, they would hit the "STO" button, and the caclulator would prompt them for a name (automatically engaging the alpha lock so that keystrokes produced letters instead of numbers):

and the user could name the variable whatever they chose. Having to turn on alpha lock, type the name, then press "STO", and hitting the "Ans" key would have been far too cumbersome for normal operations. Since all calculator functions are available in TI-BASIC, no other assignment operators were added as "STO" performed the same task, albeit backwards when compared to most other languages.

(Anecdote: TI-BASIC was one of the first languages I learned, so when I when I was first learning Java in college I felt as though assigning to the LEFT was unusual and 'backwards'!)

diceguyd30's user avatar

  • +1 I totally forgot that ! TI Basic was my very first language, too, but I don't remember this detail. –  barjak Commented Aug 4, 2011 at 7:51
  • 1 Actually the STO operator is closer to how the machine works, and how any language actually operates. The value is first calculated and then stored in memory. –  Kratz Commented Aug 4, 2011 at 12:44

Heuristic 1: When faced with more than one possible way of doing something while designing a language, pick the most common, most intuitive one, or else you will end up with Perl+.

Now, how is it more natural (at least to an English speaker)? Let's look at how we write/say things in English:

Steven is now 10 years old (as opposed to 10 years old Steven now is). I weigh more than 190 pounds (as opposed to more than 190 pounds I weigh).

The following also sounds more natural:

"If Mary is 18 yo, then she can have a candy". "If I am younger than 21 yo, then I will ask my brother to by me tequila".

"If 18 yo Mary is ..." "If 21 is greater than my age ... "

Now the code:

Note that this is not natural to either programmers nor English speakers. The sentences sound like yoda-speak, and the code is nicknamed yoda-conditions. These might be helpful in C++, but I am sure most people would agree: if a compiler could do the heavy lifting and alleviate the need for yoda-conditions, life would be a bit easier.

Of course, one could get used to anything. For examples, number 81 is written as:

Eighty One (English) Eighty and one (Spanish) One and Eighty (German).

Finally, there are 4! = 24 valid ways of saying "green apple lies on table" in Russian - the order (almost) does not matter, except that 'on' must come together with 'table'. So, if you are a native Russian speaker (for example), then you might not care whether one writes a = 10 or 10 = a because both seem equally natural.

While linguistics is a fascinating subject, I never formally studied it and do not know that many languages. Hopefully I have provided enough counter-examples though.

Elias Mårtenson's user avatar

  • 4 ... and in French, 81 is said as "four times twenty one" ... :) –  Martin Sojka Commented Aug 4, 2011 at 7:25
  • 8 @Martin That's really weird, because four times twenty one is 84. –  Peter Olson Commented Aug 4, 2011 at 15:17
  • 7 @Peter: you've got your parenthesis wrong, it's (four times twenty) one –  SingleNegationElimination Commented Aug 4, 2011 at 20:36
  • 2 In French it's actually four twenty and one , then four twenty two (sans and ) up to four twenty ten nine (99). –  Jon Purdy Commented Aug 5, 2011 at 6:07
  • 4 @Job: Reading your "If 18 yo Mary is ...", I was inevitably reminded of Yoda saying "When nine hundred years old you reach, look as good you will not, hmm?" in Return of the Jedi :-) –  joriki Commented Aug 6, 2011 at 17:32

It started with FORTRAN in the 1950s. Where FORTRAN was an abbreviation of FORmula TRANslation -- the formulas in question being simple algebraic equations which by convention always assign to the left.

Its near contemporary COBOL on the other hand was meant to be English-like and assigned to the right (mostly!).

James Anderson's user avatar

  • I think this is the best example here because it perfectly illustrates a context in a language where it's readable to a common English speaker but has right assignment. I'm saying that's important because of the large amount of people saying in English it would only read left to right for the assignment to make sense, which is absolutely not true. –  Joshua Hedges Commented Aug 16, 2018 at 18:48

Well, as @diceguyd30 pointed out, there's both notations.

  • <Identifier> = <Value> means "let Identifier be Value ". Or to expand that: Define (or redefine) the variable Identifier to Value .
  • <Value> -> <Identifier> means "store Value to Identifier ". Or to expand that: Put Value into the location designated by Identifier .

Of course, generally speaking the Identifier may in fact be any L-value.

The first approach honors the abstract concept of variables, the second approach is more about actual storage.

Note that the first approach is also common in languages, that do not have assignments. Also note, that variable definition and assignment are relatively close <Type> <Identifier> = <Value> vs. <Identifier> = <Value> .

back2dos's user avatar

It could be a remnant of early parsing algorithms. Remember that LR parsing was only invented in 1965, and it could well be that LL parsers had troubles (within the time and space limitations of the machines at the time) going the other way around. Consider:

The two are clearly disambiguated from the second token. On the other hand,

Not fun. This gets worse when you start nesting assignment expressions.

Of course, easier to disambiguate for machines also means easier to disambiguate for humans. Another easy example would be searching for the initialization of any given identifier.

Easy, just look up the left side. Right side, on the other hand

Especially when you can't grep punch cards, it's much harder to find the identifier you want.

DeadMG's user avatar

  • Precisely the point that I had thought of, yes. –  voithos Commented Aug 8, 2011 at 0:31

As has already been mentioned, pretty well all the early computer languages worked that way. E.g. FORTRAN, which came along many years before BASIC.

It actually makes a great deal of sense to have the assigned variable on the left of the assignment expression. In some languages, you might have several different overloaded routines with the SAME NAME, returning different types of result. By letting the compiler see the type of the assigned variable first, it knows which overloaded routine to call, or what implicit cast to generate when converting from (e.g.) an integer to a float. That's a bit of a simplistic explanation, but hopefully you get the idea.

Dave Jewell's user avatar

  • 2 I understand your explanation, but could not the compiler just look ahead until the end of the statement? –  voithos Commented Aug 3, 2011 at 22:57
  • That might make the lexer simpler in today's languages, but how many programming languages even supported named methods, let alone method overloads, when this kind of syntax was new? –  user Commented Aug 4, 2011 at 9:27
  • 2 Hi @voithos. Yes - the compiler could look ahead, but that would probably have been an unacceptable level of complexity in the early days of compiler writing - which was often hand-coded assembler! I think that putting the assigned variable on the left is a pragmatic choice: it's easier for both man and machine to parse. –  Dave Jewell Commented Aug 4, 2011 at 9:55
  • I think it would be trivial for an assignment to assign to the right. When a expression like 3+4==6+7, both sides are evaluated before the operator is, because the language is defined recursively. The language element 'variable = expression', could easily be changed to 'expression = variable'. Whether or not that causes ambiguous situations depends on the rest of the language. –  Kratz Commented Aug 4, 2011 at 12:51
  • 1 @Kratz - that's certainly true for compilers now, but there may have been a minor issue for very old interpreted languages that worked with tokenized source. OTOH, that might have favored variable-on-the-right rather than variable-on-the-left. –  user8709 Commented Aug 5, 2011 at 9:59

Asssembly languages have the destination as part of the left-hand opcode. Higher level languages tended to follow the conventions of the predecessor languages.

When you see = (or := for Pascalish dialects), you could pronounce those as is assigned the value , then the left-to-right nature will make sense (because we also read left-to-right in most languages). Since programming languages were predominantly developed by folks who read left-to-right, the conventions stuck.

It is a type of path dependence . I suppose if computer programming was invented by people who spoke Hebrew or Arabic (or some other right-to-left language), then I suspect we'd be putting the destination on the right.

Tangurena's user avatar

  • Yes, but I suspect that the text in the editors would be right-aligned as well... –  voithos Commented Aug 3, 2011 at 22:55
  • 8 You can't generalise like that about assembly languages. They vary as to where the destination operand is. –  quickly_now Commented Aug 3, 2011 at 23:09
  • 2 @quickly_now: right; in fact, most of the primitive machine languages (not even assemblers by today's standards) didn't even have destination, as there was usually just one or two general-purpose accumulators. most operations implied the accumulator as destination, except for 'store' opcodes, which specified only the memory address and not the source (which was the accumulator). I really don't think it was any influence on assignment syntax for ALGOL-like languages. –  Javier Commented Aug 4, 2011 at 4:34
  • 3 @Tangurena - Some assembler languages have the destimation on the left. Not of the opcode (that's the assembled object code), but the left of the arguments list for the instruction mnemonic. However, others have the destination on the right. In 68000 assembler, you'd write mov.b #255, d0 , for instance, where d0 is the register to assign to. Older assemblers only have a single argument per instruction. In the 6502 LDA #255 (Load Accumulator), you could argue that the A is on the left, but it's also on the left in STA wherever (Store Accumulator). –  user8709 Commented Aug 5, 2011 at 9:05
  • 2 And even the Intel 4004 (the 4-bit ultimate ancestor of the 8086 family, with the 8008 and 8080 in between) was developed after assignment in high level languages. If you're assuming that the 8086 series is representative of what assemblers did in the 50s and earlier, I very much doubt that's true. –  user8709 Commented Aug 5, 2011 at 9:10

For what it's worth, most statements in COBOL read from left to right, so the two operands were named first, and the destination last, like: multiply salary by rate giving tax .

I won't however, suggest that your student might prefer COBOL, for fear that I'd be (quite rightly) flagged for making such a low, uncouth, tasteless comment! :-)

Jerry Coffin's user avatar

she said that left-to-right seemed more natural to her, since that's how most of us read natural languages.

I think this is a mistake. On the one hand, you can say "assign 10 to x" or "move 10 to x". On the other hand, you can say "set x to 10" or "x becomes 10".

In other words, depending on your choice of verb, the assigned-to variable may or may not be the subject, and may or may not be on the left. So "what is natural" just depends entirely on your habitual choice of wording to represent assignment.

In pseudocode the assignment operator is very commonly written on the right. For example

In Casio calculators, even non-programmable variants, the assignment variable is also displayed on the right

In Forth the variable is on the right, too

In x86, Intel syntax has the destination on the left, but GAS syntax reverses the order, making some confusion to many people, especially on instructions regarding parameters' order like subtraction or comparisons. These instructions are the same in 2 different dialects

They both move the value in rbx to rax. No other assembly languages I know write the destination on the right like GAS.

Some platforms put the expression on the left and the variable on the right: MOVE expression TO variable COBOL expression → variable TI-BASIC, Casio BASIC expression -> variable BETA, R put expression into variable LiveCode

https://en.wikipedia.org/wiki/Assignment_%28computer_science%29#Notation

Most languages assign the value to the left, one of the reasons being easy to align the operators, easier to read and recognize the variable, as the assignment operators and variables' positions will not vary wildly in the lines, and it's easier to read as "let variable be some value".

However some people prefer to say "move value x to y" and write the variable on the right.

phuclv's user avatar

I think it follows a logical way of thinking. There has to be a box (variable) first, then you put an object (value) inside it. You don't put the object in the air and then put a box around it.

Petruza's user avatar

  • 3 yes you do. in most languages the right side is evaluated before the left one. –  Javier Commented Aug 4, 2011 at 4:35
  • 3 Its a "Driving on the Right side of the road" type of thing. It seems logical but only because its the way you have always done it. All superior countries drive on the Left. –  James Anderson Commented Aug 4, 2011 at 8:33
  • 1 @JamesAnderson superior countries? :o –  nawfal Commented Jul 22, 2014 at 21:00
  • You're right, it's only logical for a left to right writing system as the roman alphabet, which I guess is used by almost every programming language, if not all. –  Petruza Commented Jul 24, 2014 at 0:35

Not the answer you're looking for? Browse other questions tagged language-design history or ask your own question .

  • The Overflow Blog
  • Brain Drain: David vs Goliath
  • How API security is evolving for the GenAI era
  • Featured on Meta
  • Preventing unauthorized automated access to the network
  • Upcoming initiatives on Stack Overflow and across the Stack Exchange network...

Hot Network Questions

  • Round number bias in selecting operating altitude of satellites?
  • One word for someone who is Coerced
  • Arrange the 15 dominoes so that the sum of the fractions in each row is 10
  • Ban user IP address by HTTP request?
  • What does "I bought out the house" mean in this context?
  • How relevant are computer science concepts to discuss the ontological complexity of a theory?
  • Maximise linear combination of roots of unity
  • How do you respond to students complaining that practice questions are both insufficient and too easy?
  • Can you make all the squares the same color?
  • Need to replace special character "/" with another string
  • About decomposition theorem BBD with respect to some stratification
  • What is grammatical value?
  • Finding the Air resistance coefficient for a simple pendulum
  • Is it ever reasonable to infer impossibility from high improbability?
  • How to translate the term "baby" as in "burn, baby, burn?"
  • Does every variable need to be statistically significant in a regression model?
  • Travelling back to UK with ~ 3months left on EU passport
  • Sudoku solution validator/verifier/checker implemented in Java
  • How might a creature be so adapted to the temperature of its home planet that it can't survive on any other without protection?
  • Wish to draw 7 red edges going out from $x$
  • What is the advantage of catching a rocket booster with a tower?
  • A hypothetical situation in which the State cannot prevent executing a known innocent person
  • What if You Are an Individual Contributor but Your Manager Asks You to Manage Whole Projects?
  • A palindromic formula for simple convex polytopes

was the assignment of value to you

Readdressing, Reassigning, Reappraising

Faqs for ethically handling requests.

You’ve likely already come across this situation during your practice:

You've completed an assignment for a client some time back – maybe a year ago, a month ago, a week ago – and now another party wants your opinion of the value of the same property.

The request may be to readdress the report you prepared for the previous client, or to recertify or reassign it. Other times, the request might be for you to provide an update, or a letter update. Sometimes, the requesting party has no knowledge of the previously prepared report.  How should you move forward?

First, make sure you understand what’s being requested. The requesting party might not know what he or she needs, or might use labels or terms like recertification without understanding what they mean. Once you’re clear on the request, the following Q&As might help you form a response.

Assignment results are your opinions and conclusions developed specific to an assignment. Examples include your final value opinion, your highest and best use conclusion, and your indications of value from any of the approaches used. The Confidentiality Section of the Ethics Rule of USPAP and the Appraisal Institute Code of Professional Ethics provide that an appraiser must not disclose confidential information or assignment results to anyone other than the client and persons specifically authorized by the client; state enforcement agencies and such third parties as may be authorized by due process of law; and duly authorized professional peer review committees. Assignments results may be presented in a written report or in an oral report. Sometimes, if an appraiser is not careful, assignment results are revealed inadvertently. For example, an appraiser who in casual conversation tells another appraiser, another client or anyone else, “I appraised that property for $1,000,000,” is divulging assignment results.

First, keep in mind that not all portions of the report are confidential. For example, in an appraisal report, factual data such as sales comparables are not confidential (unless they were made available by the client and are not available from another source). Descriptions of the location (neighborhood description, region description, etc.) are not confidential. However, since an appraisal report contains assignment results, which are included in the Confidentiality Section of the Ethics Rule of USPAP and the Appraisal Institute Code of Professional Ethics, the authorization process stated above in Q1 applies. This means that a copy of the report that shows confidential information and assignment results can’t be given to, revealed to, or shared with anyone other than the client and persons specifically authorized by the client; state enforcement agencies; duly authorized professional peer review committees; and such third parties as may be authorized by due process of law.

Yes; however, you cannot disclose any confidential information contained in the report prepared in the previous assignment for a different client without that prior client's permission. So you must ask yourself: In completing a new assignment involving the same property for a second client, would I need to disclose information that was considered to be confidential by the first client? If so, you can’t take on the assignment without obtaining prior permission of the first client to release that confidential information. And if the first client will not give permission to use their confidential information, then you can’t accept the new assignment. In many cases, performing a new assignment for a second client would not require the appraiser to divulge any confidential information. Revisit USPAP’s definition of confidential information to be sure. Confidential Information is information that is either:

  • Identified by the client as confidential when providing it to an appraiser and that is not available from any other source.
  • Classified as confidential or private by applicable law or regulation.

A common misconception is that you must be “released” by the first client to accept the assignment with a subsequent client. The only “release” required is about confidential information. The first client does not need to give permission for you to proceed with another assignment for a second client unless confidential information is at stake. Another common misconception in performing valuation assignments is that if the value opinion in the second assignment is the same as the value opinion in the first assignment, then communicating the value opinion in the second assignment breaches confidentiality with the first client. This is not true. USPAP’s definition of assignment results is “an appraiser’s opinions or conclusions, not limited to value, that were when performing an appraisal assignment, an appraisal review assignment, or a valuation service other than an appraisal or appraisal review.” By definition, the assignment results are different because there are two different assignments – even if the numbers are the same. Note the difference between saying to Client B, “I appraised this same property for Client A for $500,000” and “My value conclusion [in the context of this assignment for you, Client B] is $500,000.” The first statement breaches confidentiality by divulging assignment results. The second statement does not. Another common misconception is that taking a subsequent assignment with another client would be a “conflict of interest.” You can’t have a conflict of interest unless you first have interest. Entering into an appraiser-client relationship to complete an assignment does not mean that you then have an interest with regard to that client or that property. This would be inconsistent with the underlying principle in USPAP that the appraiser’s role is to be independent, impartial, objective, and unbiased. Keep in mind that since 2010, USPAP has required disclosure of any prior service involving the same property within three years prior to the date of engagement. A few key points about this requirement:

  • The requirement is to disclose any service involving the property that is the subject of the appraisal (or subject of the appraisal under review, in the case of a review assignment), not just appraisals or appraisal reviews, and not just services provided as an appraiser.
  • The relevant time period is three years prior to the date of engagement of the current assignment, not date of value or date of report.
  • The disclosure must be made up front before accepting the assignment and again in the certification in the appraisal or review report.
  • There is no requirement to disclose for whom the prior service was performed; the appraised value, if any; or exactly when during the three-year period the service was performed.

The certification statement required by USPAP in Standards Rule 2-3 supplies the type and degree of disclosure: “I have performed no (or the specified) services, as an appraiser or in any other capacity, regarding the property that is the subject of this report within the three-year period immediately preceding acceptance of this assignment.” The requirement that was added to USPAP in 2010 clarifies that if the client requests that the appraisal be kept confidential, the appraiser cannot take another assignment involving that property for three years. That’s because the appraiser would not be able to disclose prior services (as required) without violating confidentiality. Use your discretion in deciding whether or not to reveal information about a prior assignment to a subsequent client beyond what’s required. For example, while the identity of the client is not confidential (unless they state that it is), there are situations in which the fact that the first client had the property appraised is, in itself, sensitive information. It’s also worth noting that it’s characteristic of professionals in many other fields to keep the identity of prior clients confidential. One caveat about taking on assignments with residential property owners/borrowers: If you’re contacted by a residential property owner or borrower about providing valuation services for which the intended use is in conjunction with mortgage lending, you must advise the property owner or borrower that the lending institution, or a third party engaged by the lender, needs to engage the appraiser for that type of assignment. This is a requirement under federal law, and the regulatory agencies have been adamant about it. Further, an appraisal report prepared for a client who is a residential property owner or borrower should clearly state that it is not intended for use by a federally insured depository institution in a federally related transaction.

No. It’s improper to readdress a report to another client for three significant reasons.

  • Changing the name of the client and then forwarding the “readdressed” report to the second client does not change the first appraiser-client relationship. An appraiser-client relationship, once established, cannot be changed. Typically, the second party wants to be named as “client” because they want the appraiser-client relationship, and all the rights and obligations thereof, to be between them and the appraiser. The only way to accomplish this is for a new appraiser-client relationship to be established. A written engagement letter with the client is a great way to establish this. In short, the only way to be named as “client” in the report is to actually be a client. “Client” is defined in USPAP as “the party or parties (i.e. individual, group, or entity) who engage an appraiser by employment or contract in a specific assignment, whether directly or through an agent”.  
  • Changing the name of the client and then forwarding the “readdressed” report to the second client could harm the confidential nature of the appraiser’s relationship with the first client. While this could be avoided by obtaining the first client’s permission to provide the report to the second client, it could still be misleading. In an appraisal assignment, if the appraiser simply changes the name of the client, the appraiser is not following the requirements under Standard 1 of USPAP to identify the client, intended user(s) and intended use with regard to this second client in the proper sequence. According to the definitions of intended use and intended user, both must be identified by the appraiser “at the time of the assignment”, not after the appraisal process is completed and the report is finished.  
  • The client is the party to whom the appraiser owes the duty of confidentiality. (Note that the appraiser does not owe a duty of confidentiality to other intended users.) And the key reason for identifying intended users has to do with Standards Rule 2-1(b), which says that the report must contain sufficient information to enable the intended users of the appraisal to understand the report properly. (In the case of a review report, a similar requirement is found in Standards Rule 3-4(b).) Once intended users and intended use are stated, the appraiser is now obligated to ensure the adequacy of the report for that use by those intended users. The identification of intended users (and intended use) must be completed up front before scope of work determination and before the report is issued. To add intended users after the fact, or to change the intended use, is putting the cart before the horse. It simply doesn’t work.

A request to readdress a report should be treated as a request to accept a new assignment involving the same property, as in Q3 above. Once the confidentiality issue is resolved, the next questions to be answered are:

  • Who are the intended users?
  • What is the intended use?
  • What date of value is needed, according to what value definition?
  • What assignment conditions (extraordinary assumptions, hypothetical conditions, supplemental standards) apply?
  • What is the appropriate scope of work for this new assignment?
  • What level of reporting is needed?

There may be little additional work in performing a new assignment for another client. You may be providing virtually the same data and analysis, and even the same value conclusion (though you won’t discover this until you have completed your analysis). However, you must consider all the assignment parameters for this new assignment, which could be different from those of the previous assignment. Further, keep in mind that in providing a report to another client, you are extending your liability to that client. As appraisers, we are not in the business of “selling reports”; we are in the business of “selling” our expertise and our opinions. Every time an addition is made to the list of intended users, our liability grows. A new client means there is a new assignment which necessitates the preparation of a new report . One additional point regarding assignments for lenders: Appraisers should be aware that the appraisal requirements of Financial Institutions Reform, Recovery, and Enforcement Act (FIRREA) allow a regulated lender to use a report that was prepared for another “financial services institution”. This means that Lender B can use a report that was prepared for Lender A, even though Lender A shows as client on the report. Lender B does not have to be named as client, according to the FIRREA requirements. However, usually Lender B will “want their name on the report”. Why? Because Lender B wants the appraiser-client relationship, and all the rights and obligations thereof, to be between them and the appraiser. This means that as far as the appraiser is concerned, there is to be a new appraiser-client relationship – i.e., a new assignment.

Reassigning may mean different things to different parties. Be sure you know what the requesting party is asking. In the context of this discussion, reassigning means signing over your rights and obligations regarding the report to another party. For example, when a report is prepared for and given to Client A, that report is no longer yours to “give”, or assign, to anyone else. An analogy would be if you sold your car to Party A, you couldn’t then sell it to Party B. Client A could assign their interests in their report to Client B, but the appraiser would not be part of this process (and should not be asked to be).

When the request is to recertify, clarification with the client is imperative. “Recertify” tends to be an abused term. Often, it is erroneously used to mean “reassign”, or “readdress”, or “update”. Often it is not clear what clients mean when they use the term “recertify”, and appraisers need to help remedy the confusion. Appraisers certify their reports (i.e., they may include a certification per SR 2-3 in an appraisal report), but this certification has nothing to do with the ownership of, or rights to use, the report. A “recertification of value” is an entirely different concept. As defined in Advisory Opinion 3 of USPAP, a re-certification of value is an assignment in which the appraiser determines whether the conditions of an appraisal have been met. This sort of assignment is not an appraisal at all, because it has nothing to do with developing an opinion of value.

No. The letter would add that party as an intended user after the completion of an assignment, and you cannot do that.

Takeaways for Future Assignments

Requests for valuation services are presented to appraisers in an assortment of ways, and the appraiser’s first tasks are to:

  • Ascertain exactly what the party is requesting.
  • Determine whether what the party is requesting is appropriate given their intended use.

When a new client enters the picture and a new appraiser-client relationship is formed, a new assignment is involved. This new assignment will require the appraiser to reconsider or reanalyze the process outlined in USPAP’s Standard 1, especially regarding identification of intended use and scope of work. A new report will be provided, appropriately identifying the party who engaged the appraiser the second time as the client. If the client is a lender subject to the requirements of FIRREA, the report will disclose prior assignments involving the same property. In a reappraisal situation, the work involved in developing the value opinion and preparing the report will likely be far less than it was the first time around. The new report may look very similar to the first. The value conclusion might even be the same, but much has changed. The appraiser has considered all parameters for a new assignment to meet the needs of the new client given their intended use, including scope of work, selection of report option, type and definition of value, date of value, etc. The appraiser has agreed to extend his or her liability to this new client. Once a report is provided to a client, it cannot be tampered with. Changing the name of the client (readdressing) is misleading because it falsifies the true relationship between the appraiser and the party who engaged the appraiser in that particular assignment. It’s unethical for clients to request this, and for appraisers to comply with such requests. Note: The Appraisal Standards Board of the Appraisal Foundation has provided additional guidance on these topics. See Advisory Opinion 25, Clarification of the Client in a Federally Related Transaction; Advisory Opinion 26, Readdressing (Transferring) a Report to Another Party; and Advisory Opinion 27, Appraising the Same Property for a New Client. Also see FAQ #120 which deals with “reliance letters.” These Advisory Opinions and FAQ are published with the Uniform Standards of Professional Appraisal Practice (USPAP) . February 2014

IMAGES

  1. Value assignment: How can I use it?

    was the assignment of value to you

  2. Week 2 DA

    was the assignment of value to you

  3. The Value Of Assignments In Your Academic Life

    was the assignment of value to you

  4. Mandatory Value assignment

    was the assignment of value to you

  5. What do you think of the value : r/pcmasterrace

    was the assignment of value to you

  6. Assignment 2 of This subject

    was the assignment of value to you

VIDEO

  1. Time Value of Money

  2. Fact/Value/Policy Assignment- Rebuttal

  3. VALUE24741GEH 30

  4. Homework"Assignment: Value Graph"

  5. Value of education,UHV assignment

  6. Fact/Value/Policy Assignment- Advocate’s Case

COMMENTS

  1. Assignment operators - assign an expression to a variable ...

    The assignment operator = assigns the value of its right-hand operand to a variable, a property, or an indexer element given by its left-hand operand. The result of an assignment expression is the value assigned to the left-hand operand.

  2. c# - IDE0059 Unnecessary assignment of a value to 'i' - Stack ...

    Unnecessary assignment of a value to 'i'. Avoid unnecessary value assignments in your code, as these likely indicate redundant value computations. If the value computation is not redundant and you intend to retain the assignment, then change the assignment target to a local variable whose name starts with an underscore and is optionally ...

  3. Assignment Operators In C++ - GeeksforGeeks

    In C++, the assignment operator forms the backbone of many algorithms and computational processes by performing a simple operation like assigning a value to a variable. It is denoted by equal sign ( = ) and provides one of the most basic operations in any programming language that is used to assign some value to the variables in C++ or in other ...

  4. Assignment (=) - JavaScript | MDN - MDN Web Docs

    The assignment (=) operator is used to assign a value to a variable or property. The assignment expression itself has a value, which is the assigned value. This allows multiple assignments to be chained in order to assign a single value to multiple variables.

  5. 1.4. Expressions and Assignment Statements — AP CSAwesome

    The assignment operator (=) allows a program to initialize or change the value stored in a variable. The value of the expression on the right is stored in the variable on the left. During execution, expressions are evaluated to produce a single value.

  6. PHP: Assignment - Manual

    The value of an assignment expression is the value assigned. That is, the value of " $a = 3 " is 3. This allows you to do some tricky things: <?php$a = ($b = 4) + 5; // $a is equal to 9 now, and $b has been set to 4.?>

  7. 1.4 — Variable assignment and initialization – Learn C++

    After a variable has been defined, you can give it a value (in a separate statement) using the = operator. This process is called assignment , and the = operator is called the assignment operator .

  8. Assignment Operators in Python - GeeksforGeeks

    The basic assignment operator is =, which simply assigns the value of the right-hand operand to the left-hand operand. Other common assignment operators include +=, -=, *=, /=, %=, and more, which perform an operation on the variable and then assign the result back to the variable.

  9. Why does the assignment operator assign to the left-hand side?

    Most languages assign the value to the left, one of the reasons being easy to align the operators, easier to read and recognize the variable, as the assignment operators and variables' positions will not vary wildly in the lines, and it's easier to read as "let variable be some value".

  10. Appraisal Institute">Readdressing, Reassigning, Reappraising - Appraisal Institute

    You've completed an assignment for a client some time back – maybe a year ago, a month ago, a week ago – and now another party wants your opinion of the value of the same property. The request may be to readdress the report you prepared for the previous client, or to recertify or reassign it.