The new printf implementation

From: Date: Fri, 22 Dec 2006 13:42:16 +0000
Subject: The new printf implementation
Groups: php.internals 
Request: Send a blank email to internals+get-27179@lists.php.net to get a copy of this message
Hi all, A couple questions regarding the printf changes (internal and userland) a couple weeks ago... Now the internal %f, %g, and %G are locale-aware, which they weren't before, right? Is this how they're supposed to be and simply weren't before? (The locale changes caused Bug #39873 with number_format(), etc.) In userland *printf(), %f (as always), %g, and %G are also locale-aware, but, like "internally," %e and %E are not? None of it really affects me, just wanting to verify desired behavior. :-) Second thing is about the g/G specifiers, especially now that they're in userland. It's my understanding that scientific notation should be used if the exponent is < -4 or >= the precision. So why with printf('%.6g', 1234567890) do I get "1234570000" instead of the expected "1.23457e+9"? The former just looks wrong. (One more digit triggers scientific notation.) Using: ini_set('precision', 6); echo (double) 1234567890; it comes out as expected, both on Windows (where zend_sprintf() appears to use the system's sprintf()), and on my Linux host. The same issue exists in Unicode mode, with double->Unicode conversion, which makes things different depending on unicode.semantics... It's a simple fix to make g/G work the way I thought (and think) they should. Thoughts? Thanks, Matt

« previous php.internals (#27179) next »