1
1

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 5 years have passed since last update.

【Ruby】数の切り上げ、切り捨て、四捨五入

Posted at

少し調べたので備忘録として

切り捨て : floor

切り上げ : ceil

四捨五入 : round

$ 1.4.round
=> 1

$ 1.5.round
=> 2

$ 1.2345.round(0)
=> 1

$ 1.2345.round(2)
=> 1.23

$ 1.2345.round(3)
=> 1.235

$ 123456.round(-2)
=> 123400



1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?