note 106082 added to function.abs

From: Date: Sat, 08 Oct 2011 10:23:58 +0000
Subject: note 106082 added to function.abs
Groups: php.notes 
Request: Send a blank email to php-notes+get-183725@lists.php.net to get a copy of this message
If doing a single conversion to ">= 0" on a random input, in order to workout the value of the input (corrected to 0 or greater), the quickest method is: $x = abs($input); After a bit more testing and thinking about how the test page (in the post below) works, it appears the results are correct, but _only_ when looping over the different methods for a lot of loops. For a single test or correction, the results are wrong. The results for option 1 and 3 are very close to each other, but option 2 is clearly the quickest of the three. After removing the loops, the results where: 1) Result [938]: 1.5974044799805E-5 sec. 2) Result [938]: 5.9604644775391E-6 sec. 3) Result [938]: 1.5020370483398E-5 sec. (note the E-5 and E-6 at the end) ---- Server IP: 117.104.162.229 Probable Submitter: 202.134.241.213 (proxied: 202.134.241.213) ---- Manual Page -- http://www.php.net/manual/en/function.abs.php Edit -- https://master.php.net/note/edit/106082 Del: integrated -- https://master.php.net/note/delete/106082/integrated Del: useless -- https://master.php.net/note/delete/106082/useless Del: bad code -- https://master.php.net/note/delete/106082/bad+code Del: spam -- https://master.php.net/note/delete/106082/spam Del: non-english -- https://master.php.net/note/delete/106082/non-english Del: in docs -- https://master.php.net/note/delete/106082/in+docs Del: other reasons-- https://master.php.net/note/delete/106082 Reject -- https://master.php.net/note/reject/106082 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183725) next »