#40482 [NEW]: Sprintf format specifier "e" output modification

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40482 [NEW]: Sprintf format specifier "e" output modification

    From: [email]kore@php.net[/email]
    Operating system: Linux 2.6.20
    PHP version: 5.2.1
    PHP Bug Type: Output Control
    Bug description: Sprintf format specifier "e" output modification

    Description:
    ------------
    There is no real category for sprintf() or string functions issues, I hope
    the selected one fits the issue.

    Between PHP 5.2.1 RC1 and PHP 5.2.1 the resulting output with the format
    specifier "e" changed. All PHP version prior to 5.2.1 tested by me have
    the same result as PHP 5.2.0.

    Even the tests were changed to reflect this new behavior:
    [url]http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/sprintf_f_2.phpt?r1=1.1.2.3&r2=1.1.2.4[/url]

    Reproduce code:
    ---------------
    $ php -r 'var_dump( sprintf( "%.3e", 0.0000234 ) );'

    Expected result:
    ----------------
    string(7) "2.34e-5"

    Actual result:
    --------------
    string(8) "2.340e-5"

    --
    Edit bug report at [url]http://bugs.php.net/?id=40482&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40482&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40482&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40482&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40482&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=40482&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=40482&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40482&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=40482&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=40482&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=40482&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=40482&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=40482&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=40482&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40482&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=40482&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=40482&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40482&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=40482&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40482&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40482&r=mysqlcfg[/url]
    kore@php.net Guest

  2. Similar Questions and Discussions

    1. #36392 [Asn->Csd]: wrong number of decimal digits with %e specifier in sprintf
      ID: 36392 Updated by: iliaa@php.net Reported By: tomas_matousek at hotmail dot com -Status: Assigned +Status: ...
    2. #39775 [NEW]: "Indirect modification ..." message is not shown
      From: toomuchphp-phpbugs at yahoo dot com Operating system: OS X PHP version: 5.2.0 PHP Bug Type: Class/Object related Bug...
    3. "Acrobat PDF file format is having difficulties expected a non-negative integer"
      Posted this in a wrong folder before. Opening many of my AI 10 docs in AI CS is getting me this error message: "Acrobat PDF file format is having...
    4. #25152 [Opn->Bgs]: output buffering functions don't catch "virtual" output
      ID: 25152 Updated by: iliaa@php.net Reported By: msarsale at buenosaires dot gov dot ar -Status: Open +Status:...
    5. "NBF"/The Next "Big" Format - The Near Future..
      Its seems that roughly every 5-10? years there comes out a new consumer format as an "alternate" to 35mm equipment for amature use. (Not including...
  3. #2

    Default #40482 [Opn->Bgs]: Sprintf format specifier "e" output modification

    ID: 40482
    Updated by: [email]tony2001@php.net[/email]
    Reported By: [email]kore@php.net[/email]
    -Status: Open
    +Status: Bogus
    Bug Type: Output Control
    Operating System: Linux 2.6.20
    PHP Version: 5.2.1
    New Comment:

    That was actually a bugfix.
    sprintf( "%.3e", 0.0000234 );
    ^^^^ it's "3 digits after the floating point"

    string(8) "2.340e-5"
    ^^^ 3 digits, not 2.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-14 12:44:18] [email]kore@php.net[/email]

    Description:
    ------------
    There is no real category for sprintf() or string functions issues, I
    hope the selected one fits the issue.

    Between PHP 5.2.1 RC1 and PHP 5.2.1 the resulting output with the
    format specifier "e" changed. All PHP version prior to 5.2.1 tested by
    me have the same result as PHP 5.2.0.

    Even the tests were changed to reflect this new behavior:
    [url]http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/sprintf_f_2.phpt?r1=1.1.2.3&r2=1.1.2.4[/url]

    Reproduce code:
    ---------------
    $ php -r 'var_dump( sprintf( "%.3e", 0.0000234 ) );'

    Expected result:
    ----------------
    string(7) "2.34e-5"

    Actual result:
    --------------
    string(8) "2.340e-5"


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40482&edit=1[/url]
    tony2001@php.net Guest

  4. #3

    Default #40482 [Bgs->Opn]: Sprintf format specifier "e" output modification

    ID: 40482
    User updated by: [email]kore@php.net[/email]
    Reported By: [email]kore@php.net[/email]
    -Status: Bogus
    +Status: Open
    Bug Type: Output Control
    Operating System: Linux 2.6.20
    PHP Version: 5.2.1
    New Comment:

    You could see the the number as the precision of the output number. You
    normally won't ever get more then one digit in front of the decimal
    point with scientific notation. Even PHP 5.2.1 acts like this:

    # php -r 'var_dump( sprintf( "%2.3e", 5555555555 ) );'
    string(8) "5.556e+9"

    If you still do not want to change the behavior back to the old one,
    the new behavior should be documented:

    [url]http://de3.php.net/manual/en/function.sprintf.php[/url] Example #2308 still
    shows the old behavior. In this case feel free to change the bugs
    category to a documentation bug.


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-02-14 12:49:04] [email]tony2001@php.net[/email]

    That was actually a bugfix.
    sprintf( "%.3e", 0.0000234 );
    ^^^^ it's "3 digits after the floating point"

    string(8) "2.340e-5"
    ^^^ 3 digits, not 2.

    ------------------------------------------------------------------------

    [2007-02-14 12:44:18] [email]kore@php.net[/email]

    Description:
    ------------
    There is no real category for sprintf() or string functions issues, I
    hope the selected one fits the issue.

    Between PHP 5.2.1 RC1 and PHP 5.2.1 the resulting output with the
    format specifier "e" changed. All PHP version prior to 5.2.1 tested by
    me have the same result as PHP 5.2.0.

    Even the tests were changed to reflect this new behavior:
    [url]http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/sprintf_f_2.phpt?r1=1.1.2.3&r2=1.1.2.4[/url]

    Reproduce code:
    ---------------
    $ php -r 'var_dump( sprintf( "%.3e", 0.0000234 ) );'

    Expected result:
    ----------------
    string(7) "2.34e-5"

    Actual result:
    --------------
    string(8) "2.340e-5"


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40482&edit=1[/url]
    kore@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139