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 摘要。