Ruby Tutorial Ruby References

Ruby - Math::E Constant



The Ruby Math::E is the Euler's constant and the base of natural logarithms. It is approximately 2.718.

Syntax

Math::E

Example:

The example below shows some usage of Math::E constant.

puts "Math::E = #{Math::E}"
puts "Math.log(Math::E) = #{Math.log(Math::E)}"
puts "Math::E ** 2 = #{Math::E ** 2}"

The output of the above code will be:

Math::E = 2.718281828459045
Math.log(Math::E) = 1.0
Math::E ** 2 = 7.3890560989306495

❮ Ruby Math Module