note 10882 deleted from language.operators by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:02:57 +0000 |
| Subject: | note 10882 deleted from language.operators by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58352@lists.php.net to get a copy of this message | ||
Note Submitter: bdiaz@aullox.com
----
Yet another IWBNI posting...
I used the caret ( ^ ) "operator" in a truncate() function of mine with a result similar
to a substraction. So, I had to implement an even weirder function which would work better. Should
anyone know of a better way to do this, I thank in advance.
//The function expects a double $num and an int $pos indicating the decimal
//positions to allow
function truncate($num,$pos){
$pos=(int)$pos;
$m="1e$pos"; //this is our divider, ten at $pos power
$t=(double)$num*(double)$m; //just to be sure
$t=(int)$t; //yes, we need to cut superfluous decimals
$t=(double)$t/(double)$m;
return $t;
}