红宝石 | BigDecimal atan()函数
BigDecimal#atan() : atan()是一个 BigDecimal 类方法,它返回反正切值到指定的精度位数,数字。
Syntax: BigDecimal.atan()
Parameter: BigDecimal values
Return: the value of arctangent to the specified number of digits of precision, numeric.
示例 #1:
# Ruby code for BigDecimal.atan() method
# loading library
require 'bigdecimal'
require 'bigdecimal/util'
require "bigdecimal/math"
include BigMath
# declaring bigdecimal
a = BigMath.atan(BigDecimal("10"), 2).to_s
# declaring bigdecimal
b = BigMath.atan(BigDecimal("0"), 1).to_s
# declaring bigdecimal
c = BigMath.atan(BigDecimal("-1"), 3).to_s
# atan() method
puts "BigDecimal a atan method : #{a}\n\n"
puts "BigDecimal b atan method : #{b}\n\n"
puts "BigDecimal c atan method : #{c}\n\n"
输出 :
BigDecimal a atan method : 0.147112767430373459205483371550142166365E1
BigDecimal b atan method : 0.0
BigDecimal c atan method : -0.7853981633974483096143979839729791083E0
示例 #2:
# Ruby code for BigDecimal.atan() method
# loading library
require 'bigdecimal'
require 'bigdecimal/util'
require "bigdecimal/math"
include BigMath
# declaring bigdecimal
a = BigMath.atan(BigDecimal("120"), 2).to_s
# declaring bigdecimal
b = BigMath.atan(BigDecimal("1.0"), 4).to_s
# declaring bigdecimal
c = BigMath.atan(BigDecimal("-3"), 1).to_s
# atan() method
puts "BigDecimal a atan method : #{a}\n\n"
puts "BigDecimal b atan method : #{b}\n\n"
puts "BigDecimal c atan method : #{c}\n\n"
输出 :
BigDecimal a atan method : 0.1562496517382685592451329995317025796273E1
BigDecimal b atan method : 0.7853981633974483096148978589729791083E0
BigDecimal c atan method : -0.127933953231702952636675255085153E1