Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

Ruby – Find Base 10 Logarithm – log10() Method – Examples & Explanation

log10() is a method in CMath class which is used to find the base 10 logarithm of any given complex number in Ruby language.

log10() Method in Ruby

log10() method exists in Standard CMath Library of Ruby. The purpose of this method is to provide base 10 logarithm of any given complex number.

 

Syntax of the log10() Method in Ruby

Syntax of log10() method is:

 

Parameters of log10() Method in Ruby

Parameter Description
xAny valid complex number. This parameter is required.

Note: If the x parameter is not a complex number, log10() method will return an error.

 

Return Value of log10()

log10() method will return base 10 logarithm of a given complex number.

 

Ruby – Get the log10() of Particular Number


Output

0.6989700043360189

 

Ruby log10() Example 1


Output

1.0+1.3643763538418412i

 

Ruby Non-Complex Number Produces Error Example 2


Output

Error

 

Ruby log10() Function Example 3


Output

1.6020599913279623

 

LearnAndLearn.com © 2018 - All rights reserved