Open In App

Ruby | Math exp() function

Last Updated : 07 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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: CPP
# 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: CPP
# 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

Next Article

Similar Reads