11

The current reputation value (rep) of StackOverflow (SO) users is mostly shown in a short form beside their name on all possible occasions. I see values like 1, 23, 345, 12.3k or 456k. Just out of interest: what abbreviation rule works behind it?

I found a partial answer on this question What reputation is needed to get the k? which leads to the conclusion that after 9,999 follows 10k, but that's just a guess, since 10,0k would also make sense, i.e. it's not clear how many digits will be shown and how/if rounding is involved (or truncating).

I think a tiny comment added to some help page should describe how the rep value is actually formatted in the SO pages?

  • @ChrisF I think my question isn't a duplicate. The question meta.stackexchange.com/q/91356/238205 that I already referred to asks for the meaning of k which was quite clear to me. I'm also interested in the number of digits (=precision). – Wolf Jan 23 '14 at 14:40
  • This is not a feature request, you don't suggest anything to add or change. – ShaWiz May 28 at 8:25
5

Purely based on my own observations, the formatting seems to be:

  • The number itself until 9,999 (using , as a delimiter between thousands and hundreds)
  • The amount of thousands with a 'k' in the end with the following rules:
    • The resulting number will have 3 digits (10.1k, 32.5k, 123k) rounded to the closest number using normal rounding rules (0-4 round down, 5-9 round up).
    • But if the reputation after rounding would be <thousands>.0, the .0 is left out resulting in only 2 digits (11k, 42k)

These rules would seem to work up to 999k.

  • The thousands/hundreds delimiter appears to be localised. I have a comma. – Joe Apr 20 '14 at 20:24
  • @Joe How on earth did I miss that.. – 3ventic Apr 20 '14 at 20:27
  • 3
    Someone will have to ask Jon Skeet to write a new rule when he ultimately breaks this one. – Nick Stauner Apr 20 '14 at 20:32
  • Thanks for sharing your observations, especially the rounding rules (including 0-truncation). I doubt that this question will ever get an "official answer", so I'll check-mark this one. – Wolf May 9 '14 at 7:03
4

I came up with this, which exactly does the same thing as SO does.

public static string ReadableReps(int reps)
{
   if (reps < 10000)
   {
       return reps.ToString("N0"); // or just N for culture specific
   }
   else return Math.Round(reps / 1000.0, 1) + "k";
}
  • +1 ...SO seems to use only the English notation for numbers. – Wolf May 5 '14 at 9:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .