Sum += 1

sum += 1
or
sum = sum + 1

Attached: patchouli_reads_siege.jpg (600x576, 59K)

sum++

I sure hope you meant ++sum

those do different things

for(int i = 1; i < 2; i++) sum + i;

sum = sum + 1 is false though

sum *= UINT_MIN

They do but in that case ++sum is the correct choice since it actually has the same result as the original.

I mean FLOAT_MIN + 1

I once faced a bug because of this. Things we think are solely theoretical can fuck us up.

You can only blame yourself for putting things you don't comprehend in your code.

unsigned int one = 1;
summ(sum,one);

>we

Attached: 1550535916619.jpg (480x480, 69K)

It's impossible to know if the program will actually sum to 1 or bug will make it sum another number, so the best way is to use a pocket calculator

According to the C book, sum+=1 can actually be compiled to faster assembly in some cases, but I don't know if modern compilers still work that way.

I think x += 1would be faster since it's an operation and assignment, where as x++ is a reference, operation, and assignment.

Just speaking from intuition though, I only know enough C++ just to get through my cooleg courses. I mostly do webshit so it's not quite my wheelhouse.

sum = lambda sum: sum+1
sum = sum(sum)

modifySTRef x (+1)

>I think x += 1would be faster since it's an operation and assignment, where as x++ is a reference, operation, and assignment.

They compile to exactly the same instructions.

++i is more efficient

only if your compiler is shit

Attached: remu_u.jpg (914x1249, 151K)

how does it feel to be retarded?

Either of these.

This is only relevant if you're incrementing it inside of a larger expression, and if you're doing that with "sum = sum + 1", you're writing valid but confusing code.

Better to write out the number then, it makes it even more mysterious why it does what it does.

good one user, you really got me there

She's right though. Any modern compiler will generate the same code if you write "++sum" as it will for "sum++". That is, assuming that you aren't using the result of the expression since then it does different things.

reimu chan gomen nasai!!!

yup

$ cat post.c
#include

int main(int argc, char **argv) {
for (int i = 0; i < 10; i++) {
printf("%d\n", i);
}
return 0;
}
$ cat pre.c
#include

int main(int argc, char **argv) {
for (int i = 0; i < 10; ++i) {
printf("%d\n", i);
}
return 0;
}
$ cc -S post.c
$ cc -S pre.c
$ diff -u post.s pre.s
--- post.s 2019-03-28 03:54:42.985322550 +0000
+++ pre.s 2019-03-28 03:54:54.921324723 +0000
@@ -1,4 +1,4 @@
- .file "post.c"
+ .file "pre.c"
.text
.section .rodata
.LC0:

I think the point being made was that if x were an expression then it'd be evaluted twice when doing x = x + 1 as opposed to x += 1 or x++

10 iterations is not nearly enough to measure any potential difference in performance.

He generated asm code from it and it was identical. There will be no performance difference.

I mean, I can make the number bigger, it still produces identical asm.

>valid but confusing
>sum = sum + 1
>confusing
Let me guess. You do frontent and nodejs stuff.

Unless its in a compound expression, the compiler treats sum++ & ++sum the same

++x is faster, x++ must return the original value, which requires a copy. x += 1 returns no value, so it will be the fastest (although the compiler will probably optimize out the return on a bare ++x).
Worth nothing that x++ and ++x aren't thread safe, as x can be modified between the increment and return statements.

sum = sum + 1 is an infinite loop in a lazy language.

Tyvm for the knowledge.

Attached: images(3).jpg (246x205, 6K)

++sum

one=1
sum2=sum
sum=sum2+one

Sum += 1;

It can be easily changed to different operator, is clear, and value can be changed quite easily.
Way better than value++ or ++value.
Value=value +1 is too verbose

succ(sum)

(incf sum)

sum = new SumFactory(new SumFactoryFactory(SumFactoryPrototype.Sets.Natural, SumFactoryPrototype.Operations.Binary.Addition).finalize()).finalize(sum).get_result_as_int();

sum1 = 1
sum = sum + sum1

Attached: 1553591576761.jpg (200x313, 10K)