Ruby | Math exp() function
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 valuesval1 = 0.98val2 = -0.9val3 = 6val4 = 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 valuesval1 = 0.67val2 = -0.12val3 = 2.4val4 = 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


