Language statistics percentages don't add up to 100% #9927

Closed
opened 2025-11-02 08:53:16 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @hr-98 on GitHub (Dec 4, 2022).

Description

This is probably just a rounding bug, but it is still a little bit frustrating when you notice it.
As you can see from the screenshot, the percentages are
COBOL 45.7%
Assembly 43.2%
Shell 5.9%
Ruby 5.3%
which is 100.1% in total.

I've made a copy of my repo here:
https://try.gitea.io/hr98/aoc22-copy-percentage-bug

Gitea Version

Gitea version 1.17.3 built with GNU Make 4.1, go1.18.7 : bindata, sqlite, sqlite_unlock_notify

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

image

Git Version

git version 2.31.1

Operating System

Linux

How are you running Gitea?

Downloaded the binary and running as systemd service on Alma Linux 9.

Database

SQLite

Originally created by @hr-98 on GitHub (Dec 4, 2022). ### Description This is probably just a rounding bug, but it is still a little bit frustrating when you notice it. As you can see from the screenshot, the percentages are COBOL 45.7% Assembly 43.2% Shell 5.9% Ruby 5.3% which is 100.1% in total. I've made a copy of my repo here: https://try.gitea.io/hr98/aoc22-copy-percentage-bug ### Gitea Version Gitea version 1.17.3 built with GNU Make 4.1, go1.18.7 : bindata, sqlite, sqlite_unlock_notify ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots ![image](https://user-images.githubusercontent.com/119700815/205487775-cbe9a345-8824-4245-b035-c676252547c9.png) ### Git Version git version 2.31.1 ### Operating System Linux ### How are you running Gitea? Downloaded the binary and running as systemd service on Alma Linux 9. ### Database SQLite
GiteaMirror added the type/bug label 2025-11-02 08:53:16 -06:00
Author
Owner

@eeyrjmr commented on GitHub (Dec 4, 2022):

This is more than likely due to rounding to 1decimal place.
changing it to 2dp would slightly improve it but I doubt this will truly ever be solved due to how floats work and all you need is the perfect combination of odd-count languages detected and odd-count files counted for it to manifest itself at some decimal position

@eeyrjmr commented on GitHub (Dec 4, 2022): This is more than likely due to rounding to 1decimal place. changing it to 2dp would slightly improve it but I doubt this will truly ever be solved due to how floats work and all you need is the perfect combination of odd-count languages detected and odd-count files counted for it to manifest itself at some decimal position
Author
Owner

@hr-98 commented on GitHub (Dec 4, 2022):

There are different things you can do to avoid such problems, like the largest remainder method.
I might try implementing it to where ever it generates the stats later, I've just never used go before.

@hr-98 commented on GitHub (Dec 4, 2022): There are different things you can do to avoid such problems, like the largest remainder method. I might try implementing it to where ever it generates the stats later, I've just never used go before.
Author
Owner

@delvh commented on GitHub (Dec 4, 2022):

Then please have a look at models/repo/language_stats.go#44-67.

@delvh commented on GitHub (Dec 4, 2022): Then please have a look at `models/repo/language_stats.go#44-67`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9927