do natural logarithms (base E or Euler) and base-10 logarithms. : Math « Development « Ruby






do natural logarithms (base E or Euler) and base-10 logarithms.


Math.log(Math::E) # => 1.0
Math.log(1) # => 0.0
Math.log(0) # => -Infinity
Math.log10(100.0) # => 2.0

 








Related examples in the same category

1.Math functions from the Math module
2.The Math Object
3.The Math.exp function returns Euler to the power of x.
4.Call to the class method sqrt from the Math module
5.Taking Logarithms
6.Random number
7.Random seeds
8.Convert the Cartesian point (x,y) to polar (magnitude, angle) coordinates
9.Convert polar coordinates to Cartesian coordinates