This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: handling inf/nan in '%f'
Type: Stage:
Components: Interpreter Core Versions: Python 2.6
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: cdavid, cito, eric.smith, mark.dickinson
Priority: normal Keywords: patch

Created on 2009-01-01 07:52 by cdavid, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
nan.patch cdavid, 2009-01-01 07:52 handle nan and inf in '%f'
Messages (4)
msg78693 - (view) Author: Cournapeau David (cdavid) Date: 2009-01-01 07:52
On windows, with python 2.6,  s = '%s' % float('inf') is 'inf', but s =
'%f' % float('inf') is equal to '1.#INF'.

This patch fixes the inconsistency, by using the code from floatobject.f
format_float into stringobject.c formatfloat. I think it would be better
to use the same underlying implementations for both functions, but it is
not so easy, because format_float cannot fail (return void), whereas
formatfloat can (return error code).
msg84579 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-03-30 16:50
Assigning to Eric, at his request.
msg85822 - (view) Author: Christoph Zwerschke (cito) * Date: 2009-04-09 17:45
This is a related problem on Windows:

'%g' % 1e400 -> '1.#INF'
'%.f'  % 1e400 --> '1'
msg85905 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2009-04-12 16:19
I believe this is a duplicate of issue 4482. I'm closing this and will
add everyone who is nosy on this to be nosy on 4482.
Date User Action Args
2022-04-11 14:56:43adminsetgithub: 49049
2009-04-12 16:19:41eric.smithsetstatus: open -> closed
resolution: duplicate
messages: + msg85905
2009-04-09 17:45:47citosetnosy: + cito
messages: + msg85822
2009-03-30 16:50:03mark.dickinsonsetassignee: mark.dickinson -> eric.smith

messages: + msg84579
nosy: + eric.smith
2009-02-11 13:45:38mark.dickinsonsetassignee: mark.dickinson
nosy: + mark.dickinson
2009-01-01 07:52:46cdavidcreate