From d2fc5fd34e07d178f5c9299b9dbd29ed4b9688e7 Mon Sep 17 00:00:00 2001 From: Jeroen van Wolffelaar Date: Sun, 12 Aug 2001 21:37:24 +0000 Subject: [PATCH] Fix that rand() bug; double->float; better min() documentation; possibly something else I don't remember right now :-) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@54456 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/math.xml | 88 +++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 36 deletions(-) diff --git a/functions/math.xml b/functions/math.xml index 14d035bb5d..85cf3fd8be 100644 --- a/functions/math.xml +++ b/functions/math.xml @@ -1,4 +1,4 @@ - + Mathematical Functions Math @@ -8,8 +8,9 @@ Introduction These math functions will only handle values within the range of - the long and double types on your computer. If you need to - handle bigger numbers, take a look at the integer and float types on your computer. + (this corresponds currently to the C types long resp. double) + If you need to handle bigger numbers, take a look at the arbitrary precision math functions. @@ -140,8 +141,8 @@ Returns the absolute value of number. If the argument number is of type float, the return type is also float, - otherwise it is int (as float usually has a - bigger value range than int). + otherwise it is integer (as float usually has a + bigger value range than integer). @@ -440,8 +441,8 @@ $binary = base_convert ($hexadecimal, 16, 2); Description - double deg2rad - double number + float deg2rad + float number @@ -579,7 +580,7 @@ var_dump(hexdec("a0")); Description - double lcg_value + float lcg_value void @@ -652,14 +653,14 @@ var_dump(hexdec("a0")); If the first parameter is an array, max returns the highest value in that array. If the first parameter - is an integer, string or double, you need at least two parameters + is an integer, string or float, you need at least two parameters and max returns the biggest of these values. You can compare an unlimited number of values. - If one or more of the values is a double, all the values will be - treated as doubles, and a double is returned. If none of the - values is a double, all of them will be treated as integers, and + If one or more of the values is a float, all the values will be + treated as floats, and a float is returned. If none of the + values is a float, all of them will be treated as integers, and an integer is returned. @@ -674,10 +675,14 @@ var_dump(hexdec("a0")); Description - mixed min - mixed arg1 - mixed arg2 - mixed argn + number min + number arg1 + number arg2 + ... + + + number min + array numbers @@ -685,17 +690,20 @@ var_dump(hexdec("a0")); parameter values. - If the first parameter is an array, min - returns the lowest value in that array. If the first parameter - is an integer, string or double, you need at least two parameters + In the first variant, you need at least two parameters and min returns the lowest of these values. You can compare an unlimited number of values. - If one or more of the values is a double, all the values will be - treated as doubles, and a double is returned. If none of the - values is a double, all of them will be treated as integers, and - an integer is returned. + In the second variant, min + returns the lowest value in numbers. + + + If one or more of the values is a float, all the values + will be + treated as floats, and a float is returned. If none of the + values is a float, all of them will be treated as integers, + and an integer is returned. @@ -708,13 +716,17 @@ var_dump(hexdec("a0")); Description + + int mt_rand + + int mt_rand int - min + min int - max + max @@ -782,7 +794,7 @@ var_dump(hexdec("a0")); // seed with microseconds since last "whole" second -mt_srand ((double) microtime() * 1000000); +mt_srand ((float) microtime() * 1000000); $randval = mt_rand(); @@ -806,7 +818,7 @@ $randval = mt_rand(); int mt_getrandmax - void + @@ -945,7 +957,7 @@ $randval = mt_rand(); Description - double pi + float pi void @@ -1027,8 +1039,8 @@ echo pow(-1, 5.5); // error Description - double rad2deg - double number + float rad2deg + float number @@ -1049,13 +1061,17 @@ echo pow(-1, 5.5); // error Description + + int rand + + int rand int - min + min int - max + max @@ -1098,8 +1114,8 @@ echo pow(-1, 5.5); // error Description - double round - double val + float round + float val int precision @@ -1192,7 +1208,7 @@ $foo = round (1.95583, 2); // $foo == 1.96 // seed with microseconds since last "whole" second -srand ((double) microtime() * 1000000); +srand ((float) microtime() * 1000000); $randval = rand(); @@ -1245,5 +1261,5 @@ sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: -vim: ts=4 sw=4 et syntax=sgml +vim: ts=1 sw=1 et syntax=sgml -->