4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

整数同士の除算演算子の挙動(Elixir)

Posted at

はじめに

Elixir

a b a / b a % b div(a, b) rem(a, b)
5 4 1.25 SyntaxError 1 1
5 -4 -1.25 SyntaxError -1 1
-5 4 -1.25 SyntaxError -1 -1
-5 -4 1.25 SyntaxError 1 -1

Wrapping Up

  • /はいつもfloatになります
  • %はありません(SyntaxErrorになります)
  • 整数で結果が欲しい場合には、商が欲しいときはdiv/2を、余りが欲しいときにはrem/2を使います
  • Enjoy Elixir ! :rocket::rocket::rocket: :lgtm::lgtm::lgtm:
4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?