Error:

Check if the string is a valid number

def is_num?(str)
  begin
    !!Integer(str)
  rescue ArgumentError, TypeError
    false
  end
end

Compare two numbers

8 <=> 9 # => -1
8 <=> 8 # => 0
9 <=> 8 # => 1

Round float number

(1.5).round # => 2

Generate random number in range

f = rand(1..10) # => integer random from 1 to 10

Convert decimal number to binary

255.to_s(2) # => "11111111"

Convert decimal number to hex

255.to_s(16) # => "ff"

Convert decimal number to oct

255.to_s(8) # => "377"

Convert binary number to decimal

"10101100".to_i(2) # => 172

Convert hex number to decimal

"a0".to_i(16) # => 160

Convert oct number to decimal

"0755".to_i(8) # => 493

Euler constant

Math::E # => 2.718281828459045

Pi constant

Math::PI # => 3.141592653589793

Calculate natural logarithm

Math.log(Math::E)    #=> 1.0
Math.log(Math::E**3) #=> 3.0

Trigonometric functions

Math.sin(Math::PI) # => 1.2246467991473532e-16
Math.cos(Math::PI) # => -1.0
Math.tan(Math::PI) # => -1.2246467991473532e-16

Find maximum number

[1, 5, 0].max # => 5

Find minimum number

[1, 5, 0].min # => 0

Calculate absolute value of the number

(-1.23).abs # => 1.23

Calculate exponent

Math.exp(2)#  => 7.38905609893065

Calculate power

2**3 # => 8