\[\large\underline{\textbf{Addition-Assignment}}\]
The `=` symbol in computer science is slightly different to the \(=\) symbol of mathematics. `=` represents the assignment operator, a (perhaps temporary) definition. In mathematics, assignment is often denoted with \(:=\). When a variable is to be reassigned to a value that is: the old value of the variable plus some additional term; \(x := x + a\) In computer science this is written as: `x = x + a`, or using a simpler syntax, (where `+=` denotes addition-assignment): `x += a`. \(\underline{\text{My question is:}}\) \(\textit{What is the best way to represent this addition-assignment in }\LaTeX\)? [I don't think \(x :+= a\) looks right at all]
\[\huge\color{green}{+=}\]:P
but, there is too much space between the chars
i want something more like:\[\large x:\!\!\!+\!\!\!=a\]
don't u like space between numbers variables :P
it should look like the addition-assignment is a single symbol
\(\large\color{green}{{\rm -=+}}\) is it right ? :D
no?
question mark lol okay
maybe \[\large x \operatorname{:\!\!\!+} a\]
So use of negative space? \(\large x:\!\!\!+\!\!\!=a\) seems a bit tight. \(\large x:\!\!+\!\!=a\) One less on both sides. \(\large x:\!\!+\!\!\!=a\) One less on the left. \(\large x:\!\!\!+\!\!=a\) One left on the right.
first one looks right
\[x\operatorname{:\!\!+\!\!=}a\]\[x\operatorname{:\!\!-\!\!=}a\]\[x\operatorname{:\!\!\times\!\!=}a\]\[x\operatorname{:\!\!\div\!\!=}a\] hmmm
\[\boxed{ \newcommand \peq {\operatorname{\mathop{:=}^+}} % += addition assignment \newcommand \teq {\operatorname{\mathop{:=}^-}} % -= take-away assignment \newcommand \meq {\operatorname{\mathop{:=}^\times}}% *= multiplication assignment \newcommand \deq {\operatorname{\mathop{:=}^\div}} % /= division assignment }%unk\]\[ x := x+a\iff x\peq a\\[3ex] x := x-a\iff x\teq a\\[3ex] x := x\times a\iff x\meq a\\[3ex] x := x/a\iff x\deq a\]
So that: \[\texttt{x = x + 1}\\ \texttt{x += 1}\\ \texttt{x++}\] performs the mathematical operation: \[x:=x+1\\ x\peq 1\\ \newcommand \pp {\!+\!\!+} % ++ plus-plus x\pp\]
Join our real-time social learning platform and learn together with your friends!