Ruby | Math log10() function

The log10() function in Ruby returns the base 10 logarithm value of X.

Syntax: Math.log10(X)

Parameter: The function takes one mandatory parameter X whose base 10 logarithm value is to be returned.



Return Value: The function the base 10 logarithm value of X.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for log10() function 
  
# Assigning values
val1 = 213
val2 = 256
val3 = 27 
val4 = 100 
  
# Prints the value returned by log10() 
puts Math.log10(val1)
  
puts Math.log10(val2)
  
puts Math.log10(val3)
  
puts Math.log10(val4)

chevron_right


Output:

2.3283796034387376
2.4082399653118496
1.4313637641589874
2.0

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for log10() function 
  
# Assigning values
val1 = 21
val2 = 2
val3 = 19
val4 = 121
  
# Prints the value returned by log10() 
puts Math.log10(val1)
  
puts Math.log10(val2)
  
puts Math.log10(val3)
  
puts Math.log10(val4)

chevron_right


Output:

1.3222192947339193
0.3010299956639812
1.2787536009528289
2.08278537031645

Reference: https://devdocs.io/ruby~2.5/math#method-c-log10



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.