Page 1 of 1
Math equations in PHP?
Posted: Tue Oct 11, 2005 3:58 pm
by J_Iceman05
Is it possible to use certain mathematic tools in php.
For example, pi is there a function that emulates pi in php, or would i have to make my own and use 3.14 (or more digits such as 3.141592653589) to imitate pi?
Also for things such as Euler's number e (which goes something to this effect 2.718281828459045)
Thanks in advanced for any help you can give.
Posted: Tue Oct 11, 2005 4:02 pm
by pickle
To get the value of pi, you can call pi() or use the constant M_PI. The value of e can be found with the M_E constant.
Pi function:
http://www.php.net/pi
Math functions:
http://www.php.net/manual/en/ref.math.php
Posted: Tue Oct 11, 2005 4:03 pm
by Charles256
actually i'm beginning work on a math library:-/ i don't know of anything built into PHP but once I get a new site design (hopefully within the next week) i'll start posting up math functions as open source.
Posted: Tue Oct 11, 2005 4:05 pm
by feyd
math related constants: (php 5.0.4)
Code: Select all
'M_E' => 2.71828182846,
'M_LOG2E' => 1.44269504089,
'M_LOG10E' => 0.434294481903,
'M_LN2' => 0.69314718056,
'M_LN10' => 2.30258509299,
'M_PI' => 3.14159265359,
'M_PI_2' => 1.57079632679,
'M_PI_4' => 0.785398163397,
'M_1_PI' => 0.318309886184,
'M_2_PI' => 0.636619772368,
'M_2_SQRTPI' => 1.1283791671,
'M_SQRT2' => 1.41421356237,
'M_SQRT1_2' => 0.707106781187,
'INF' => INF,
'NAN' => 0,
Thank you
Posted: Tue Oct 11, 2005 4:14 pm
by J_Iceman05
Thank you all very much for your input.
It's exactly what I was looking for.
This helps a lot.