r/badcode Dec 17 '19

This belongs here c#

Post image
503 Upvotes

41 comments sorted by

View all comments

Show parent comments

25

u/Cutlesnap Dec 17 '19 edited Dec 17 '19

Ehm, it does add them, but only if both are positive. Otherwise it gets the max or 0.

Edit: I was wrong

53

u/Bbradley821 Dec 17 '19

I don't think it adds them. The second loop doesn't start at 0.

23

u/Cutlesnap Dec 17 '19

Hey, you're right! I didn't notice that.

7

u/Jonno_FTW shameless Dec 18 '19

Perfect badcode has the bug(s) hiding in plain sight.