note 7982 deleted from Type Juggling by jimw
| From: | jimw@php.net | Date: | Thu, 11 Jan 2001 02:51:19 +0000 |
| Subject: | note 7982 deleted from Type Juggling by jimw | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9609@lists.php.net to get a copy of this message | ||
We are using the money type of variable in a postgres database. When retrieving mfg_list_price, we
needed to recast this string as a numeric variable before doing multiplication. I came up with the
following solution:
<pre>
$mfg_list_price=ereg_replace("[^0-9.]","",$mfg_list_price);
#strip the leading $ sign
$mfg_list_price++;
$mfg_list_price--;
Our programmer, Joy Chen, noticed that this did not work properly -- every mfg_list_price was 0.01
higher than it ought to be. The solution was to substitute $mfg_list_price=$mfg_list_price+1; for
$mfg_list_price++; when recasting the variable.
This led to the proper solution.