Ruby | BigDecimal atan() function

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 :



filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

BigDecimal a atan method : 0.147112767430373459205483371550142166365E1

BigDecimal b atan method : 0.0

BigDecimal c atan method : -0.7853981633974483096143979839729791083E0


Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.