intcomma returns scientific notation for large floats
维护者通常 2 天内回复
评估
调研方向
从 intcomma() 入口开始,复现报告中的大浮点数和小浮点数示例。跟踪浮点数格式化路径,并添加覆盖测试,表明 1e16 和 0.00001 等值使用带分组的十进制表示法,与 issue 中的预期输出一致。
由索引模型根据 Issue 内容生成。
描述
intcomma() returns scientific notation for floats of 1e16 and above, with no commas added:
>>> humanize.intcomma(1e15)
'1,000,000,000,000,000.0'
>>> humanize.intcomma(1e16)
'1e+16'
>>> humanize.intcomma(1.5e20)
'1.5e+20'
I expected '10,000,000,000,000,000.0' and '150,000,000,000,000,000,000.0'. Passing ndigits works around it (intcomma(1e16, 0) gives '10,000,000,000,000,000').
This happens because f"{value:,}" on a float uses the same formatting as repr(), and that switches to an exponent at 1e16. Small floats hit the same thing, e.g. intcomma(0.00001) returns '1e-05'.
- 主要语言
- Python
- 星标
- 760
- 派生
- 166
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 7
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-humanize/humanize 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
python-humanize/humanize#438 ·
维护者通常 2 天内回复
-
docs: document how to run the test suite locally可能已有人在做 @yuefdev 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
python-humanize/humanize#430 ·
维护者通常 2 天内回复
-
metric() adds a digit when a value rounds into quetta可能已有人在做 @SashaMIT 于 5 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
python-humanize/humanize#423 ·
维护者通常 2 天内回复
-
precisedelta() silently drops the sign of negative timedeltas可能已有人在做 @Mukller 于 42 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
python-humanize/humanize#379 ·
维护者通常 2 天内回复
-
`naturalsize()` raises `ValueError` for custom format strings with text可能已有人在做 @Sanjays2402 于 66 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
python-humanize/humanize#366 ·
维护者通常 2 天内回复
查看 python-humanize/humanize 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
modelcontextprotocol/python-sdk#3648 ·
维护者通常 1 天内回复
-
docs good first issue
难度 2/5 1-3 小时 新手友好度 78/100
VenetoStato/giorgio#6 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 70/100
EclipseFdn/open-vsx.org#13831 ·
维护者通常 1 天内回复