In languages like C++
, there is an expression like x += y
.
If x
had already been occupied by a specific floating number (e.g. 3.0
), is there any FLOP count difference between the following two?
x += 1.0
x = x + 1.0
Edited
To be specific, in languages such as Python
, there is indeed the difference between
- x+= 1.0
- x = x+1.0
where the first indicates the modification of the data-structure itself, and the second corresponds to the reassignment of the variable. (Reference : What is the difference between i=i+1 and i+=1 in a for loop?
For FLOP
counts, one may be interested in the following two things:
- the number of
+
s - the number of
*
s
so it might be natural for a novice to C++
as me to wonder about the difference between the FLOP counts of the two.
As the answerer points out, the difference can show up even in C++
when we use volatile
objects.