note 69806 added to ref.bc

From: Date: Thu, 21 Sep 2006 20:37:19 +0000
Subject: note 69806 added to ref.bc
Groups: php.notes 
Request: Send a blank email to php-notes+get-117393@lists.php.net to get a copy of this message
The Greatest Common Denominator of two large numbers, using BCMath functions. Please read the PHP manual for BCMath requirements. It works even for those who cannot have GMP support in their PHP distribution, for instance due to the web host policy. You can see a demo here: http://www.freephpcalculator.tk/ Code: // License: free to do whatever you want with the code // even using it function bcgcd ($value1, $value2) { if ($value1 < $value2) // Swap $value1 and $value2 { $temp = $value1; $value1 = $value2; $value2 = $temp; } // We use the Euclid's algorithm // for finding the Greatest Common Denominator (GCD) $mod = 1; while ($mod != 0) { $mod = bcmod ($value1, $value2); $value1 = $value2; $value2 = $mod; } return $value1; } ---- Server IP: 66.163.161.117 Probable Submitter: 81.181.76.242 ---- Manual Page -- http://www.php.net/manual/en/ref.bc.php Edit -- https://master.php.net/note/edit/69806 Del: integrated -- https://master.php.net/note/delete/69806/integrated Del: useless -- https://master.php.net/note/delete/69806/useless Del: bad code -- https://master.php.net/note/delete/69806/bad+code Del: spam -- https://master.php.net/note/delete/69806/spam Del: non-english -- https://master.php.net/note/delete/69806/non-english Del: in docs -- https://master.php.net/note/delete/69806/in+docs Del: other reasons-- https://master.php.net/note/delete/69806 Reject -- https://master.php.net/note/reject/69806 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117393) next »