Return to log.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / math |
1.1 misho 1: --TEST-- 2: log() tests 3: --FILE-- 4: <?php // $Id: log.phpt 242949 2007-09-26 15:44:16Z cvs2svn $ 5: echo "On failure, please mail result to php-dev@lists.php.net\n"; 6: for ($x = 0, $count= 0; $x < 200; $x++) { 7: $x2 = (int) exp(log($x)); 8: // e ^ log(x) should be close in range to x 9: if (($x2 < ($x + 2)) && ($x2 > ($x - 2))) { 10: $count++; 11: } else { 12: print "$x : $x2\n"; 13: } 14: } 15: print $count . "\n"; 16: 17: // Now test the base form of log 18: for ($base = 2; $base < 11; $base++) { 19: for ($x = 0, $count= 0; $x < 50; $x++) { 20: $x2 = (int) pow($base, log($x, $base)); 21: // base ^ log(x) should be close in range to x 22: if (($x2 < ($x + 2)) && ($x2 > ($x - 2))) { 23: $count++; 24: } else { 25: print "base $base: $x : $x2\n"; 26: } 27: } 28: print $count . "\n"; 29: } 30: ?> 31: --EXPECT-- 32: On failure, please mail result to php-dev@lists.php.net 33: 200 34: 50 35: 50 36: 50 37: 50 38: 50 39: 50 40: 50 41: 50 42: 50