This is a discussion on Mathematical functions in PHP within the PHP Programming forums, part of the Web Development category; The following two statements are functionally identical. The bcpowmod() version however, executes in less time and can accept larger parameters. ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| The following two statements are functionally identical. The bcpowmod() version however, executes in less time and can accept larger parameters. PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| Sponsored Links |
| |||
| deg2rad() function The deg2rad() function converts a degree to its radian number. Syntax deg2rad(degree_number) Example 1 <?php echo deg2rad("30") . "<br />"; echo deg2rad("10") . "<br />"; echo deg2rad("1587") . "<br />"; echo deg2rad("70"); ?> The output of the code above will be: 0.523598775598 0.174532925199 27.6983752292 1.2217304764
__________________ Thanks Regards Sureshbabu Harikrishnan ![]() +91 9884320017 |
| |||
| Hi, To Set default scale parameter for all bc math functions we can use bcscale() function. This function sets the default scale parameter for all subsequent bc math functions that do not explicitly specify a scale parameter. For e.g PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| To get the square root of an arbitrary precision number we can use bcsqrt() function For example PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| To subtract one arbitrary precision number from another we can use bcsub() PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| The atan() function returns the arctangent of a number as a numeric value between -PI/2 and PI/2 radians. <?php echo(atan(0.50) . "<br />"); echo(atan(-0.50) . "<br />"); echo(atan(5) . "<br />"); echo(atan(10) . "<br />"); echo(atan(-5) . "<br />"); echo(atan(-10)) ?> ans: 0.463647609001 -0.463647609001 1.37340076695 1.4711276743 -1.37340076695 -1.4711276743 |
| |||
| The atan2() function returns the angle theta of an (x,y) point as a numeric value between -PI and PI radians. <?php echo(atan2(0.50,0.50) . "<br />"); echo(atan2(-0.50,-0.50) . "<br />"); echo(atan2(5,5) . "<br />"); echo(atan2(10,20) . "<br />"); echo(atan2(-5,-5) . "<br />"); echo(atan2(-10,10)) ?> ans 0.785398163397 -2.35619449019 0.785398163397 0.463647609001 -2.35619449019 -0.785398163397 |
| |||
| Hi, mt_srand() Definition and Usage The mt_srand() function seeds the random number generator for mt_rand(). This function should be called only once per script, and it must be called before any calls to mt_rand().
__________________ Regards, Senraj.A |
| |||
| Hi, In this example we will seed the random number generator: PHP Code: 1132656473
__________________ Regards, Senraj.A |
| |||
| Hi, mt_srand() Note: In PHP 4.2.0 and later, there is no need to seed the random generator with mt_srand(). This is done automatically. Tip: The greater the randomness of the seed, the more random number you'll get. A suitable number to seed this function with, is mktime().
__________________ Regards, Senraj.A |
| |||
| Math functions will handle values in the range of the integer and float types. These are predefined functions within library.
__________________ web design company |
| |||
| Hi, The pow() Definition and Usage function raises the first argument to the power of the second argument, and returns the result. Example PHP Code: 16 36 36 0.0277777777778 -1.#IND
__________________ Regards, Senraj.A |
| |||
| Nice one examples buddy.
__________________ web design company |
| |||
| Hi, These mathematical functions are used to create arithmetical calculation and logic in a web page. For example while generating the reports of anything, there we can go for these functions.
__________________ With, J. Jeyaseelan Everything Possible |
| |||
| Hi, pi() Definition and Usage The pi() function returns the value of PI. Example PHP Code: 3.14159265359
__________________ Regards, Senraj.A |
| |||
| The mt_rand() function returns a random integer using the Mersenne Twister algorithm. If this function is called without parameters, it returns a pseudo-random value between 0 and RAND_MAX. If you want a random number between 10 and 100 (inclusive), use mt_rand (10,100). <?php echo(mt_rand() . "<br />"); echo(mt_rand() . "<br />"); echo(mt_rand(10,100)) ?> The output of the code above could be: 1150905288 613289478 21 |
| |||
| The rad2deg() function converts a radian number to its degree. <?php $rad = M_PI; $deg = rad2deg($rad); echo "$rad radians is equal to $deg degrees"; ?> The output of the code above will be: 3.14159265359 radians is equal to 180 degrees |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| COM functions in php | Kamalakannan | PHP Programming | 24 | 07-12-2008 03:20 AM |
| PHP FTP Functions | Kamalakannan | PHP Programming | 54 | 04-14-2008 04:42 AM |
| erroneous results for certain mathematical calculations | aramesh | Flash Actionscript Programming | 1 | 04-03-2008 02:00 AM |
| Sql functions | itbarota | Database Support | 11 | 02-29-2008 01:08 AM |
| What are Virtual Functions? How to implement virtual functions in "C"? | Sabari | C and C++ Programming | 4 | 09-10-2007 10:35 PM |