Find out exactly how many upvotes and downvotes for Reddit posts

Xuan Wu
2 min readFeb 27, 2020

--

As mentioned earlier, I posted the demos of my Chinese input method on Reddit, and received quite some feedback. For example, this post below now shows 1 upvote & 55% upvoted earlier, and now 2 upvote & 58% upvoted:

Obviously, the number of upvotes is “relative”, which is the number of upvotes minus # of downvotes. Otherwise the “upvoted” ratio doesn’t make sense. The problem is, what I prefer to know is exactly how many upvotes there are, as it tells the popularity of this demo, and the potential user group size of my project.

Luckily, with these two values, the “relative” upvote number, and upvoted ratio, it’s sufficient to get what I want for this post.

It’s simple, elementary school level (I suppose?) math.

Let’s start with 1 upvote, 55% upvoted.

Say “up” is the exact # of upvotes, and “down” is that of downvotes. We now know:

  1. up = down + 1
  2. up/(up+down) = 55%

Now the tricky part is, 55% isn’t necessary the accurate value, as the percentage is most likely rounded. Use JavaScript to show what “round” does:

Math.round(54.2)
54
Math.round(54.6)
55

So, it’s a bit tricky to use old-school equation solving in this case. In fact, the solution would be: up=5.5, down=4.5, which doesn’t really make sense, as upvotes and downvotes only can be exact natural numbers, like 1, 2, 3, …

OK, what to do now?

Simple: we try every number pairs: {up:1, down:0}, {up:2, down:1}, etc. Then calculate corresponding upvoted ratio, and round it, to see if it’s equal to 55%.

Let’s do it manually first:

{1,0}: 1/1+0 = 1

{2,1}: 2/2+1 = 0.66666.., rounded to 67%

{3,2}: 3/3+2 = 0.6 = 60%

{4,3}: 4/4+3 = 0.5714.., rounded: 57%, getting closer to 55%!

{5,4}: 5/5+4 = 0.5555…, rounded: 56%, even closer!

{6,5}: 6/6+5 = 0.5454…, rounded: 55%, yeah here it is!

So, actually my post already got 6 upvotes, when it showed only 1 relative upvotes. Not bad!

Now, I’m guessing, when it shows 2 relative upvotes now, there are 7 upvotes (1 more upvote) and 5 downvotes. Upvote ratio would be 7/7+5 = 0.58333, rounded to 58%, exactly the same as shown now:

Seems all good?

Practically speaking, this method applies to all the cases other than one special scenario: 0 relative upvotes and 50% upvoted ratio, meaning there are exactly same number of upvotes and downvotes. In such case, I don’t see any way to tell exactly how many each type of votes (please enlighten me!).

Anyways, I’m happy with what I see, and my project will surely continue.

Most likely, I’ll make a simple web app to do the math for future usage, because, although fun as it seems, I’d rather not do all the math every single time ;)

--

--