Advertisement
sci4me

that time i forgot C

Dec 15th, 2018
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. while(*dp) { *dp -= 1; *(dp + offset) += factor; }
  2.  
  3. // is not the same as; top works, bottom doesn't
  4.  
  5. *(dp + offset) += *dp * factor;
  6. *dp = 0;
  7.  
  8. // neither does this:
  9.  
  10. u64 a = 0;
  11. while(*dp) { *dp -= 1; a += factor; }
  12. *(dp + offset) += a;
  13.  
  14. // i chose u64 in case it overflows a u8
  15. // u8 doesn't work either
  16.  
  17. // the top one must work because it handles overflows differently than the other two...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement