BigDecimal#cos() : cos() is a BigDecimal class method which returns the value of cosine to the specified number of digits of precision, numeric.
Syntax: BigDecimal.cos()
Parameter: BigDecimal values
Return: the value of cosine to the specified number of digits of precision, numeric.
Example #1 : Example for cos() method
# Ruby code for BigDecimal.cos() method # loading library require 'bigdecimal'
require 'bigdecimal/util'
require "bigdecimal/math"
include BigMath # declaring bigdecimal a = BigMath.cos(BigDecimal( "10" ), 2 ).to_s
# declaring bigdecimal b = BigMath.cos(BigDecimal( "0" ), 1 ).to_s
# declaring bigdecimal c = BigMath.cos(BigDecimal( "-1" ), 3 ).to_s
# cos() method puts "BigDecimal a cos method : #{a}\n\n"
puts "BigDecimal b cos method : #{b}\n\n"
puts "BigDecimal c cos method : #{c}\n\n"
|
Output :
BigDecimal a cos method : -0.83907152907645246825216692820607553E0 BigDecimal b cos method : 0.1E1 BigDecimal c cos method : 0.540302305868139718063666551191971443E0
Example #2 :
# Ruby code for BigDecimal.cos() method # loading library require 'bigdecimal'
require 'bigdecimal/util'
require "bigdecimal/math"
include BigMath # declaring bigdecimal a = BigMath.cos(BigDecimal( "120" ), 2 ).to_s
# declaring bigdecimal b = BigMath.cos(BigDecimal( "1.0" ), 4 ).to_s
# declaring bigdecimal c = BigMath.cos(BigDecimal( "-3" ), 1 ).to_s
# cos() method puts "BigDecimal a cos method : #{a}\n\n"
puts "BigDecimal b cos method : #{b}\n\n"
puts "BigDecimal c cos method : #{c}\n\n"
|
Output :
BigDecimal a cos method : 0.81418097052656177616342509565903133E0 BigDecimal b cos method : 0.540302305868139717171666551191971443E0 BigDecimal c cos method : -0.9899924966004454524570754831726682E0