note 109658 added to function.bcmod

From: Date: Mon, 06 Aug 2012 18:53:48 +0000
Subject: note 109658 added to function.bcmod
Groups: php.notes 
Request: Send a blank email to php-notes+get-189934@lists.php.net to get a copy of this message
If you don't have bcmath installed and you need to use it. You may need these functions: <?php if(!function_exists('bcmul')){ function bcmul($left_operand, $right_operand, $scale = 0) { return round($left_operand * $right_operand, $scale); } } if(!function_exists('bcdiv')){ function bcdiv($left_operand, $right_operand, $scale = 0) { return number_format($left_operand / $right_operand, $scale); } } if(!function_exists('bcmod')){ function bcmod($left_operand, $modulus) { return $left_operand - ($modulus * floor($left_operand / $modulus)); } } if(!function_exists('bcadd')){ function bcadd($left_operand, $right_operand, $scale = 0) { return round($left_operand + $right_operand, $scale); } } /* TEST */ echo '<pre>'; echo bcadd('1.234', '5'); // 6 echo "\r\n"; echo bcadd('1.234', '5', 4); // 6.2340 echo "\r\n"; echo bcmod('4', '2'); // 0 echo "\r\n"; echo bcmod('2', '4'); // 2 echo "\r\n"; echo bcdiv('105', '6.55957', 3); // 16.007 echo "\r\n"; echo bcmul('1.34747474747', '35', 3); // 47.161 echo "\r\n"; echo bcmul('2', '4'); // 8 echo '</pre>'; ?> ---- Server IP: 69.147.83.197 Probable Submitter: 200.62.245.148 ---- Manual Page -- http://www.php.net/manual/en/function.bcmod.php Edit -- https://master.php.net/note/edit/109658 Del: integrated -- https://master.php.net/note/delete/109658/integrated Del: useless -- https://master.php.net/note/delete/109658/useless Del: bad code -- https://master.php.net/note/delete/109658/bad+code Del: spam -- https://master.php.net/note/delete/109658/spam Del: non-english -- https://master.php.net/note/delete/109658/non-english Del: in docs -- https://master.php.net/note/delete/109658/in+docs Del: other reasons-- https://master.php.net/note/delete/109658 Reject -- https://master.php.net/note/reject/109658 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189934) next »