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