[v][sf]printf additions (#, E, g, G)
| From: | Matt W | Date: | Thu, 20 Jul 2006 12:20:46 +0000 |
| Subject: | [v][sf]printf additions (#, E, g, G) | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-24760@lists.php.net to get a copy of this message | ||
Hi,
I've wished there was a *printf() float specifier that wouldn't include
trailing zeros/point, as simply converting to string (echo, %s, etc.) can
result in scientific notation, which I *don't* want (%g in
convert_to_string()). The only other way that would result in what I want
is number_format() with my "no-extra-zeros option" patch. ;-) So I was
originally looking for how to NOT pad %f to the specified precision, then I
thought why not add more of the stuff from C? (And I see it's marked "not
done" in formatted_print.c.)
Can/should I go ahead and add support for the # flag/specifier, g/G, and E
(the missing compliment to e)? Make everything work like C, except # used
with f/F, which would mean "remove trailing 0's/point" -- as C's behavior
with # and f (add point even when precision=0?) can be done in PHP. (I
assume C's is for when precision is specified with * + parameter?)
Thoughts?
Thanks,
Matt