Advertisement
aokmikey

Untitled

Nov 23rd, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1. numberToComma(numtoconvert)
  2. {
  3.     x = string(numtoconvert);
  4.     formatted = "";
  5.     if(x.size <= 3)
  6.         return numtoconvert;
  7.  
  8.     for( i = x.size - 3; i >= 0; i -= 3 )
  9.     {
  10.         if ( i > 0 )
  11.             formatted += "," + getsubstr(x, i, 3 + i);
  12.         else
  13.             formatted += getsubstr(x, i, 3);
  14.     }
  15.     if ( i < 0 )
  16.         formatted = getsubstr(x, 0, 3 + i) + formatted;
  17.  
  18.     return formatted;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement