PHP to Ruby
Convert PHP code into Ruby!
-
pi
Posted on April 2nd, 2009 No commentsReturns the value of PI to 14 (default) decimal places. This precision can be altered in the php.ini file.
PHP
echo pi(); // => 3.1415926535898
Ruby
puts Math::PI; # => 3.14159265358979
In the code above, PI is actually a constant of the Module Math. PHP also has a constant which stores the approximate value of PI - M_PI.
PHP
echo M_PI(); // => 3.1415926535898


