Issue 4799: handling inf/nan in '%f' (original) (raw)

Issue4799

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

Files
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.
History
Date User Action Args
2022-04-11 14:56:43 admin set github: 49049
2009-04-12 16:19:41 eric.smith set status: open -> closedresolution: duplicatemessages: +
2009-04-09 17:45:47 cito set nosy: + citomessages: +
2009-03-30 16:50:03 mark.dickinson set assignee: mark.dickinson -> eric.smithmessages: + nosy: + eric.smith
2009-02-11 13:45:38 mark.dickinson set assignee: mark.dickinsonnosy: + mark.dickinson
2009-01-01 07:52:46 cdavid create