[PR #13583] format: use binary prefixes for HumanBytes file size formatting #76574

Open
opened 2026-05-05 09:12:31 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13583
Author: @nathannewyen
Created: 12/30/2025
Status: 🔄 Open

Base: mainHead: fix/size-rounding-error


📝 Commits (1)

  • 524486b format: use binary prefixes for HumanBytes file size formatting

📊 Changes

2 files changed (+35 additions, -28 deletions)

View changed files

📝 format/bytes.go (+13 -8)
📝 format/bytes_test.go (+22 -20)

📄 Description

Change HumanBytes to use binary prefixes (1024-based) instead of decimal (1000-based) for file size formatting.

This fixes the rounding error where 3072 bytes was displayed as "3.1 KB" instead of "3 KB".

The decimal constants (KiloByte, MegaByte, etc.) are preserved for other uses like buffer sizes and memory capacity.

Fixes #13405


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13583 **Author:** [@nathannewyen](https://github.com/nathannewyen) **Created:** 12/30/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/size-rounding-error` --- ### 📝 Commits (1) - [`524486b`](https://github.com/ollama/ollama/commit/524486b412a21f620d0fd7b9a6f62194f525c2fc) format: use binary prefixes for HumanBytes file size formatting ### 📊 Changes **2 files changed** (+35 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `format/bytes.go` (+13 -8) 📝 `format/bytes_test.go` (+22 -20) </details> ### 📄 Description Change `HumanBytes` to use binary prefixes (1024-based) instead of decimal (1000-based) for file size formatting. This fixes the rounding error where 3072 bytes was displayed as "3.1 KB" instead of "3 KB". The decimal constants (`KiloByte`, `MegaByte`, etc.) are preserved for other uses like buffer sizes and memory capacity. Fixes #13405 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 09:12:31 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#76574