Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Ruby | Math exp() function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The exp() function in Ruby returns the value of e^value. It takes value in range [-inf, +inf] and returns the answer in range [0, infinity].

Syntax: Math.exp(value)

Parameter: The function takes the value which is to be raised to the power of e.

Return Value: The function returns the value of e^value.

Example 1:




# Ruby program for exp() function 
  
# Assigning values
val1 = 0.98
val2 = -0.9
val3 = 6
val4 = 1
  
# Prints the exp() value 
puts Math.exp(val1)
puts Math.exp(val2)
puts Math.exp(val3)
puts Math.exp(val4)

Output:

2.664456241929417
0.4065696597405991
403.4287934927351
2.718281828459045

Example 2:




# Ruby program for exp() function 
  
# Assigning values
val1 = 0.67
val2 = -0.12
val3 = 2.4
val4 = 89
  
  
# Prints the exp() value 
puts Math.exp(val1)
puts Math.exp(val2)
puts Math.exp(val3)
puts Math.exp(val4)

Output:

1.9542373206359396
0.8869204367171575
11.023176380641601
4.4896128191743455e+38

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

My Personal Notes arrow_drop_up
Last Updated : 07 Jan, 2020
Like Article
Save Article
Similar Reads