athityakumar / athityakumar/colorls
[bug] rounding for small files
- Dominant language
- Ruby
- Stars
- 5.1k
- Forks
- 396
- PR merge metrics
- No merged PRs in 30d
Description
Please read: **Rounding** bug for **large** files #600 and its #622 PR.
**Human-readable** **rounds wrong** the file size in **small** files. In this case to 1KiB instead to 2KiB (1731 ÷ 1024 = 1.69 → should round up to 2)
```
> colorls -l settings.vim
rw-rw---- 1 user user 1 KiB Thu Apr 17 12:43:33 2025 settings.vim
> colorls -l -h settings.vim
rw-rw---- 1 user user 1 KiB Thu Apr 17 12:43:33 2025 settings.vim
```
`--no-human-readable` works fine
```
> colorls -l --no-human-readable settings.vim
rw-rw---- 1 user user 1731 B Thu Apr 17 12:43:33 2025 settings.vim
```
Both `ls -l` and `stat` confirm it
```
> ls -l settings.vim
-rw-rw---- 1 user user 1731 Apr 17 12:43 settings.vim
> stat settings.vim
File: settings.vim
Size: 1731 Blocks: 8 IO Block: 4096 regular file
[...]
```
**Request**. If possible show 1 decimal precision (alike `1.7 KiB`), otherwise proper round to the right natural value please.
Thanks in advance!
colorls --version: 1.5.0
OS: 24.04.1-Ubuntu
Contributor guide
Research direction
Start by reproducing the human-readable output for a 1731-byte file, then trace colorls's file-size formatting path; the issue does not name a source file or test. Done means human-readable output rounds this value to 2 KiB or displays about 1.7 KiB, while --no-human-readable remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100