PHP 4.0 Bug #1029 Updated: printf (& sprintf) dosn't handle exponential format for floats correctly
| From: | jimw@php.net | Date: | Sat, 10 Feb 2001 17:55:06 +0000 |
| Subject: | PHP 4.0 Bug #1029 Updated: printf (& sprintf) dosn't handle exponential format for floats correctly | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-46152@lists.php.net to get a copy of this message | ||
ID: 1029
Updated by: jimw
Reported By: leif.thuresson@tsl.uu.se
Status: Open
Bug Type: Feature/Change Request
Assigned To:
Comments:
really reassigned to 4.0 this time.
Previous Comments:
---------------------------------------------------------------------------
[1999-11-12 11:31:07] joey@cvs.php.net
Moving to feature req.
---------------------------------------------------------------------------
[1999-01-05 06:29:54] leif.thuresson@tsl.uu.se
System: Linux, Apache with PHP-module
Problem: printf (& sprintf) dosn't handle exponential format for floats correctly
Comment: This isn't actually a bug since it isn't documented to work in the manual.
I nedded exponential format in my application and since the function
"formatted_print.c" already had some support for exp. format (but
not working correctly) the simplest solution was to fix it in the php source code.
Below is my patch to "formatted_print.c" if you would like to include it
in a future rease of PHP.
Thanks for a great tool for building web interfaces to databases !
Regards,
-leif
*** formatted_print.c.org Mon Jan 4 21:06:38 1999
--- formatted_print.c Mon Jan 4 21:13:09 1999
***************
*** 257,263 ****
} else if (precision > MAX_FLOAT_PRECISION) {
precision = MAX_FLOAT_PRECISION;
}
! cvt = _php3_cvt(number, precision, &decpt, &sign, (fmt == 'e'));
if (sign) {
numbuf[i++] = '-';
--- 257,266 ----
} else if (precision > MAX_FLOAT_PRECISION) {
precision = MAX_FLOAT_PRECISION;
}
! if (fmt == 'e')
! cvt = _php3_cvt(number, precision+1, &decpt, &sign, 1);
! else
! cvt = _php3_cvt(number, precision, &decpt, &sign, 0);
if (sign) {
numbuf[i++] = '-';
***************
*** 288,294 ****
while (cvt[j]) {
numbuf[i++] = cvt[j++];
}
!
numbuf[i] = '