Tag Archives: 切り捨て

プログラミング: 切り捨てが floor, 切り上げが ceil になのはなぜか

Sorry, this entry is only available in 日本語.

多くのプログラミング言語で、数値の切り捨てfloor, 切り上げceil という関数で実現できるようになっています。 これをなかなか覚えられないという方もいると思いますので、確実に思い出せるようにするために、その理由を解説しました。

Continue reading プログラミング: 切り捨てが floor, 切り上げが ceil になのはなぜか

Ruby: Round Down with some decimal places

Memorized the way to round down number to the nth decimal places in Ruby.

The number like 0.81235 (Float) has function floor, which round down the number to zeal number, can’t round down to some decimal places.

Environment

  • Ruby 2.2.3p173
  • OS: Ubuntu 15.04
Continue reading Ruby: Round Down with some decimal places