module

Math

v1_8_7_330 - Show latest stable

The Math module contains module functions for basic trigonometric and transcendental functions. See class Float for a list of constants that define Ruby’s floating point accuracy.

Constants

E = rb_float_new(M_E)

E = rb_float_new(exp(1.0))

PI = rb_float_new(M_PI)

PI = rb_float_new(atan(1.0)*4.0)

Files

  • lib/complex.rb
  • lib/mathn.rb
  • math.c

1Note

Input for trigonometric functions must be radians

emime · Mar 31, 2009

You must use radians to have the right result. For example to compute the sin of 125 degrees use:

Math.sin(125*Math::PI/180)