📜  红宝石 | CMath acos() 方法

📅  最后修改于: 2022-05-13 01:55:17.388000             🧑  作者: Mango

红宝石 | CMath acos() 方法

acos() 方法是 CMath 类,用于返回给定值的反余弦值。

示例 #1:

# Ruby code for acos() method
require 'cmath'
  
# Initialize value 
a = 0.3584
b = 2
  
# Printing result  
puts "acos value of a : #{CMath.acos(a)}\n\n"
puts "acos value of b : #{CMath.acos(b)}\n\n"

输出:

acos value of a : 1.204242852965772

acos value of b : 0.0+1.3169578969248164i

示例 #2:

# Ruby code for acos() method
require 'cmath'
  
# Initialize value 
a = 0
b = -0.247
  
# Printng result   
puts "acos value of a : #{CMath.acos(a)}\n\n"
puts "acos value of b : #{CMath.acos(b)}\n\n"

输出:

acos value of a : 1.5707963267948966

acos value of b : 1.8203794286756558