note 111275 added to ref.bc

From: Date: Fri, 01 Feb 2013 16:31:51 +0000
Subject: note 111275 added to ref.bc
Groups: php.notes 
Request: Send a blank email to php-notes+get-193481@lists.php.net to get a copy of this message
As dawidgarus mentioned before, using BC Math in more complicated math formulas is very confusing. So I have started the project BN-PHP. Object BN\Number supports basic math operations (+, -, *, /, \, % [real number modulo], ^, sqrt, abs, negate), round operations (basic round, floor, ceil, round to number) and comparison of numbers. Example: <?php $a = new BN\Number('0.1'); $b = new BN\Number('0.7'); $ten = new BN\Number('10'); echo $a->add($b)->multiply($ten)->roundDown(); // 8 ?> But if you write math formulas only with this Number you can see that it's still very confusing. Because of that expression evaluator is part of the project: <?php $evaluator = new \BN\Expression\ExpressionEvaluator(); $operatorsFactory = new BN\Expression\OperatorsFactory(); $evaluator->setOperators($operatorsFactory->getAllOperators()); echo $evaluator->evaluate('floor((0.1+0.7)*10)'); // 8 ?> More information about project are available at Bitbucket (mercurial/git hosting) - find project 'BN-PHP'. ---- Server IP: 69.147.83.199 Probable Submitter: 84.16.127.76 ---- Manual Page -- http://php.net/manual/en/ref.bc.php Edit -- https://master.php.net/note/edit/111275 Del: integrated -- https://master.php.net/note/delete/111275/integrated Del: useless -- https://master.php.net/note/delete/111275/useless Del: bad code -- https://master.php.net/note/delete/111275/bad+code Del: spam -- https://master.php.net/note/delete/111275/spam Del: non-english -- https://master.php.net/note/delete/111275/non-english Del: in docs -- https://master.php.net/note/delete/111275/in+docs Del: other reasons-- https://master.php.net/note/delete/111275 Reject -- https://master.php.net/note/reject/111275 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193481) next »