Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Ruby | BigDecimal atan() function

  • Last Updated : 06 Dec, 2019

BigDecimal#atan() : atan() is a BigDecimal class method which returns the value of arctangent to the specified number of digits of precision, numeric.

Syntax: BigDecimal.atan()

Parameter: BigDecimal values

Return: the value of arctangent to the specified number of digits of precision, numeric.

Example #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"

Output :

BigDecimal a atan method : 0.147112767430373459205483371550142166365E1

BigDecimal b atan method : 0.0

BigDecimal c atan method : -0.7853981633974483096143979839729791083E0


Example #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"

Output :

BigDecimal a atan method : 0.1562496517382685592451329995317025796273E1

BigDecimal b atan method : 0.7853981633974483096148978589729791083E0

BigDecimal c atan method : -0.127933953231702952636675255085153E1




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!