Ruby BigDecimal atan()函数
BigDecimal#atan() : atan()是BigDecimal类的一个方法,用于返回精度为指定位数的正切值,数值。
语法。BigDecimal.atan()
参数。BigDecimal的值
返回:以指定精度的数字为单位的正切值,数值。
例子 #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