Ruby | BigDecimal PI() function Last Updated : 06 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report BigDecimal#PI() : PI() is a BigDecimal class method which returns the value of pi to the specified number of digits of precision, numeric. Syntax: BigDecimal.PI() Parameter: BigDecimal values Return: the value of pi to the specified number of digits of precision, numeric. Example #1 : Ruby # Ruby code for BigDecimal.PI() method # loading library require 'bigdecimal' require 'bigdecimal/util' require "bigdecimal/math" include BigMath # declaring bigdecimal a = BigMath.PI(10).to_s # declaring bigdecimal b = BigMath.PI(102).to_s # declaring bigdecimal c = BigMath.PI(2).to_s # PI() method puts "BigDecimal a PI method : #{a}\n\n" puts "BigDecimal b PI method : #{b}\n\n" puts "BigDecimal c PI method : #{c}\n\n" Output : BigDecimal a PI method : 0.3141592653589793238462643388813853786957412E1 BigDecimal b PI method : 0.3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306913173228884424E1 BigDecimal c PI method : 0.31415926535897932388671233672993238433E1 Example #2 : Ruby # Ruby code for BigDecimal.PI() method # loading library require 'bigdecimal' require 'bigdecimal/util' require "bigdecimal/math" include BigMath # declaring bigdecimal a = BigMath.PI(78).to_s # declaring bigdecimal b = BigMath.PI(12).to_s # declaring bigdecimal c = BigMath.PI(1).to_s # PI() method puts "BigDecimal a PI method : #{a}\n\n" puts "BigDecimal b PI method : #{b}\n\n" puts "BigDecimal c PI method : #{c}\n\n" Output : BigDecimal a PI method : 0.31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253422571844827786301E1 BigDecimal b PI method : 0.314159265358979323846264338336544487694763327962E1 BigDecimal c PI method : 0.31415926535897932364198143965603E1 Comment More infoAdvertise with us Next Article Ruby | BigDecimal E() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby BigDecimal-class Similar Reads Ruby | BigDecimal to_i() function BigDecimal#to_i() : to_i() is a BigDecimal class method which returns the value as an Integer. Syntax: BigDecimal.to_i() Parameter: BigDecimal values Return: the value as an Integer. Example #1 : Ruby # Ruby code for BigDecimal.to_i() method # loading library require 'bigdecimal' require 'bigdecimal 1 min read Ruby | BigDecimal E() function BigDecimal#E() : E() is a BigDecimal class method which returns the value of arctangent to the specified number of digits of precision, numeric. Syntax: BigDecimal.E() Parameter: BigDecimal values Return: the value of arctangent to the specified number of digits of precision, numeric. Example #1 : R 2 min read Ruby | BigDecimal precs function BigDecimal#precs() : precs() is a BigDecimal class method which checks whether the BigDecimal value is nan value. Syntax: BigDecimal.precs() Parameter: BigDecimal values to check regarding the NaN value. Return: true : if value is a NaN value otherwise return false Example #1 : Ruby # Ruby code for 1 min read Ruby | BigDecimal log() function BigDecimal#log() : log() is a BigDecimal class method which returns the natural logarithm of decimal to the specified number of digits of precision, numeric. Syntax: BigDecimal.log() Parameter: BigDecimal values Return: the natural logarithm of decimal to the specified number of digits of precision, 2 min read Ruby | BigDecimal quo() function BigDecimal#quo() : quo() is a BigDecimal class method which divides the two BigDecimal values. Syntax: BigDecimal.quo() Parameter: BigDecimal values Return: Divides the two BigDecimal values. Example #1 : Example for quo() method Ruby # Ruby code for BigDecimal.quo() method # loading library require 2 min read Ruby | BigDecimal to_int() function BigDecimal#to_int() : to_int() is a BigDecimal class method which returns the value as an Integer. Syntax: BigDecimal.to_int() Parameter: BigDecimal values Return: the value as an Integer. Example #1 : Ruby # Ruby code for BigDecimal.to_int() method # loading library require 'bigdecimal' require 'bi 1 min read Like