intcomma returns exponential notation for large floats

未關閉 適合新手
#521 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@Omarinho12345 已經在處理了。

開始於 2026年11月19日。

  • #522 來自 @Omarinho12345 —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
72/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
backend

研究方向

先找出 intcomma() 及其測試,再重現回報中 intcomma(1e16) 與 intcomma(10**16) 之間的差異;issue 未提及檔案路徑。檢查格式化流程如何處理 1e16 及以上的浮點數,同時保留 ndigits 原有的行為。當大型浮點數回傳 '10,000,000,000,000,000.0' 且相關測試通過時,即為完成。

由索引模型根據 Issue 內容生成。

描述

Description

intcomma() returns exponential notation instead of a comma-grouped number for
large floats. The exponent form starts at 1e16, while the equivalent integer
and smaller floats are grouped correctly.

Reproduction

>>> import humanize
>>> humanize.intcomma(1e16)
'1e+16'
>>> humanize.intcomma(10**16)
'10,000,000,000,000,000'
>>> humanize.intcomma(1e15)
'1,000,000,000,000,000.0'

Expected

intcomma(1e16) should be '10,000,000,000,000,000.0', matching the behaviour
for floats below 1e16.

Cause

f"{value:,}" falls back to scientific notation for floats at or above 1e16,
which bypasses the comma grouping. The ndigits path is not affected.

主要語言
Python
星號
768
分支
243
平均合併
4 天 12 小時
30 天內合併 PR
19

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

python-humanize/humanize 的其他 Issue

查看 python-humanize/humanize 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。