End of Life Ruby 3.2 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);
domain_check_range(d, -1.0, 1.0, "acos");
return DBL2NUM(acos(d));
}
Returns the arc cosine of x.
-
Domain:
[-1, 1]. -
Range:
[0, PI].
Examples:
Example
acos(-1.0) # => 3.141592653589793 # PI acos(0.0) # => 1.5707963267948966 # PI/2 acos(1.0) # => 0.0