除算の違い。
# Ruby puts 3.to_f / 2 #=> 1.5 puts 3 / 2 #=> 1 # Python print(3 / 2) # => 1.5 print(3 // 2) # => 1 # Elixir ※1.4以降 require Integer IO.puts(3 / 2) # => 1.5 IO.puts(Integer.floor_div(3, 2)) # => 1
剰余の違い。
# Ruby puts 5 % 2 #=> 1 # Python print(5 % 2) # => 1 # Elixir ※1.4以降 require Integer IO.puts(Integer.mod(5, 1)) # => 1
べき乗の違い
# Ruby puts 2 ** 3 #=> 8 # Python print(2 ** 3) # => 8 # Elixir ※Erlangの関数使用 IO.puts(:math.pow(2,3)|> round) # => 8