End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Math.acos
Math.acos(x) → Float
math.c
View on GitHub ↗
static VALUE
math_acos(VALUE unused_obj, VALUE x)
{
double d;
d = Get_Double(x);
/* check for domain error */
if (d < -1.0 || 1.0 < d) domain_error("acos");
return DBL2NUM(acos(d));
}
Computes the arc cosine of x. Returns 0..PI.
Domain: [-1, 1]
Codomain: [0, PI]
Example
Math.acos(0) == Math::PI/2 #=> true