ec429

It's still ugly though

Feb 6th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. private static String BackwardsNumCheck(ulong Num, String src)
  2. {
  3.     Num = Num > 9 ? '9' : (char)Num + '0'; // could use a Max() here, if the platform has one?  In C it'd be a macro...
  4.     int len = src.Length();
  5.     int i;
  6.     bool carry = false;
  7.     String ret = new String(' ', len); // I hope I can treat this like an array.  String classes are ick.
  8.     for (i = len; i--; ) {
  9.         ret[i] = src[i] + (carry ? 1 : 0);
  10.         if (carry = (ret[i]++ > Num)) {
  11.             ret[i] = '1';
  12.         }
  13.     }
  14.     return ret;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment