note 82412 deleted from function.round by jani
| From: | jani@php.net | Date: | Thu, 10 Apr 2008 08:46:26 +0000 |
| Subject: | note 82412 deleted from function.round by jani | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-138094@lists.php.net to get a copy of this message | ||
Note Submitter: kjohnson at zootweb dot com
----
Regarding the change of behavior where round now returns certain values in exponential notation,
here's a third way this can bite you (see previous Notes below for ways one and two).
Say you have to this code to build a stored procedure call. If you pass round() one of the
"special values", e.g., '1200000', and you get a return value in exponential
notation, e.g., '1.2E+6', you will likely have a mismatch of types between the resulting
value in the procedure call (a string) and the database column definition (likely a decimal for
monetary values), yielding yet another failed transaction:
<?
// assume $totalDebt contains 1200000
$sql =
"exec update_loan_financials
@application_id='$appID',
@total_debt=" . round($totalDebt); // string '1.2E+6'
?>
If it matters, a poster on the PHP General mail list said that this new behavior is actually a
property of the float type, in general, not the round function, in particular. Replace your round()
call with a cast to float and you'll see the exact same result.
It doesn't matter to me, I just know my code is breaking.