What is the implementation of reputation points formatting used on Stack Overflow?
Like, 10000
reputation points is displayed as 10k
.
And 1000
is displayed as 1,000
.
And sometimes, it is rounded and then a k
is added.
Finally, after no one came up on this, I've found a way which replicates what SO does, approximately.
Here is the C#-code which I used and will use in my website ;)
public static string ReadableReps(int reps)
{
return reps < 10000
? reps.ToString("N0") // or just N for culture specific
: Math.Round(reps / 1000.0, 1) + "k";
}
else
. Because return
terminates the current function thats being executed.
Commented
May 4, 2014 at 11:21
16.6k
, but on posts it is currently just 16.5k
. Seems like today or yesterday things changed.
Commented
May 27, 2015 at 22:45
chat
you see users with2.2k
reputation, for instance: chat.stackoverflow.com/users/2312574/mikedidthis