Ruby | BigDecimal log() function Last Updated : 06 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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, numeric. Example #1 : Ruby # Ruby code for BigDecimal.log() method # loading library require 'bigdecimal' # declaring bigdecimal a = BigDecimal("10") # declaring bigdecimal b = BigDecimal("1000") *2 # declaring bigdecimal c = BigDecimal("11.43") # log() method puts "BigDecimal a log method : #{Math.log(a)}\n\n" puts "BigDecimal b log method : #{Math.log(b)}\n\n" puts "BigDecimal a log method : #{Math.log(c)}\n\n" Output : BigDecimal a log method : 2.302585092994046 BigDecimal b log method : 7.600902459542082 BigDecimal a log method : 2.4362414778067194 Example #2 : Ruby # Ruby code for BigDecimal.log() method # loading library require 'bigdecimal' # declaring bigdecimal a = BigDecimal('12')*12 # declaring bigdecimal b = BigDecimal('10')+(22 ** 7.1) ** 10 # declaring bigdecimal c = -BigDecimal('-3') # log() method puts "BigDecimal a log method : #{Math.log(a)}\n\n" puts "BigDecimal b log method : #{Math.log(b)}\n\n" puts "BigDecimal a log method : #{Math.log(c)}\n\n" Output : BigDecimal a log method : 4.969813299576001 BigDecimal b log method : 219.46401418844042 BigDecimal a log method : 1.0986122886681098 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 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 PI() function 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 co 2 min read Ruby | BigDecimal round() function BigDecimal#round() : round() is a BigDecimal class method which rounds the Big decimal to the nearest integer. Syntax: BigDecimal.round() Parameter: BigDecimal values Return: rounds the Big decimal to the nearest integer. Example #1 : Ruby # Ruby code for BigDecimal.round() method # loading library 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 to_r() function BigDecimal#to_r() : to_r() is a BigDecimal class method which returns the value of Big decimal as a rational number. Syntax: BigDecimal.to_r() Parameter: BigDecimal values Return: the value of Big decimal as a rational number Example #1 : Ruby # Ruby code for BigDecimal.to_r() method # loading libra 1 min read 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 Like