note 108606 added to function.bcpow

From: Date: Thu, 10 May 2012 00:18:46 +0000
Subject: note 108606 added to function.bcpow
Groups: php.notes 
Request: Send a blank email to php-notes+get-187562@lists.php.net to get a copy of this message
If anyone else is also going nuts with the second argument being casted to an integer -- see https://bugs.php.net/bug.php?id=10116 -- (and thus being unable to calculate roots using bcpow), I wrote a convenient wrapper around BCMath functions that solves this problem (while respecting PEMDAS): <?php var_dump(BC('4.0 ^ 0.5')); // 2 var_dump(BC('4.0 ^ 2.5')); // 32 var_dump(BC('4.8 ^ 2.5')); // 2.1908902300207... var_dump(BC('4.0 ^ 1 / 3')); // 1.3333333333333... var_dump(BC('4.0 ^ (1 / 3)')); // 1.5874010519682... var_dump(BC('4.0 ^ 2.5 >= 4.0 ^ 0.5')); // 1 ?> The source is a bit long to post here, but you can get it at https://github.com/alixaxel/phunction/blob/c9e276713d3981a08043a95cc94cf96f264e39d4/phunction/Math.php#L74. ---- Server IP: 194.8.30.16 Probable Submitter: 95.136.100.108 ---- Manual Page -- http://www.php.net/manual/en/function.bcpow.php Edit -- https://master.php.net/note/edit/108606 Del: integrated -- https://master.php.net/note/delete/108606/integrated Del: useless -- https://master.php.net/note/delete/108606/useless Del: bad code -- https://master.php.net/note/delete/108606/bad+code Del: spam -- https://master.php.net/note/delete/108606/spam Del: non-english -- https://master.php.net/note/delete/108606/non-english Del: in docs -- https://master.php.net/note/delete/108606/in+docs Del: other reasons-- https://master.php.net/note/delete/108606 Reject -- https://master.php.net/note/reject/108606 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#187562) next »