[PR #14842] fix: preserve decimal precision in HumanBytes for values >= 10 #46119

Open
opened 2026-04-25 01:38:57 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14842
Author: @LincolnBurrows2017
Created: 3/14/2026
Status: 🔄 Open

Base: mainHead: fix-human-bytes-decimal


📝 Commits (2)

  • c48be94 fix: correct typo ViewSeperator -> ViewSeparator in deepseekocr model
  • a09e4e8 fix: preserve decimal precision in HumanBytes for values >= 10

📊 Changes

3 files changed (+9 additions, -5 deletions)

View changed files

📝 format/bytes.go (+2 -2)
📝 format/bytes_test.go (+5 -0)
📝 model/models/deepseekocr/model.go (+2 -3)

📄 Description

Summary

In format/bytes.go, the HumanBytes function had a logic error:

Problem: When value >= 10 has decimals (like 15.5 TB), it incorrectly displays as "15 TB", losing decimal precision.

Fix: Changed the order of checks to check decimals first:

// Before (wrong)
switch {
case value >= 10:
    return fmt.Sprintf("%d %s", int(value), unit)
case value != math.Trunc(value):
    return fmt.Sprintf("%.1f %s", value, unit)
}

// After (correct)
switch {
case value != math.Trunc(value):
    return fmt.Sprintf("%.1f %s", value, unit)
case value >= 10:
    return fmt.Sprintf("%d %s", int(value), unit)
}

🔄 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/14842 **Author:** [@LincolnBurrows2017](https://github.com/LincolnBurrows2017) **Created:** 3/14/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-human-bytes-decimal` --- ### 📝 Commits (2) - [`c48be94`](https://github.com/ollama/ollama/commit/c48be94ac71ffe697cb92e7ca4b8eecd6d93826b) fix: correct typo ViewSeperator -> ViewSeparator in deepseekocr model - [`a09e4e8`](https://github.com/ollama/ollama/commit/a09e4e88df885360421f6fafa839b284b690d1eb) fix: preserve decimal precision in HumanBytes for values >= 10 ### 📊 Changes **3 files changed** (+9 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `format/bytes.go` (+2 -2) 📝 `format/bytes_test.go` (+5 -0) 📝 `model/models/deepseekocr/model.go` (+2 -3) </details> ### 📄 Description ## Summary In `format/bytes.go`, the `HumanBytes` function had a logic error: **Problem:** When value >= 10 has decimals (like 15.5 TB), it incorrectly displays as "15 TB", losing decimal precision. **Fix:** Changed the order of checks to check decimals first: ```go // Before (wrong) switch { case value >= 10: return fmt.Sprintf("%d %s", int(value), unit) case value != math.Trunc(value): return fmt.Sprintf("%.1f %s", value, unit) } // After (correct) switch { case value != math.Trunc(value): return fmt.Sprintf("%.1f %s", value, unit) case value >= 10: return fmt.Sprintf("%d %s", int(value), unit) } ``` --- <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-04-25 01:38:57 -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#46119