LoginSignup
0
0

More than 1 year has passed since last update.

円の方程式/円周率/ルート/切り捨て/切り上げ(Ruby)

Posted at

Ruby3.1
MathモジュールPI
Mathモジュールsqrt
Floatクラスfloor
Floatクラスceil

xy軸の座標で(0,0)を中心点とする
円の方程式  x² × y² = 半径²

#円周率
p = Math::PI
puts p
# => 3.141592653589793

#平方根を求める方法:√2の場合
Math.sqrt(2)
# => 1.4142135623730951

#小数点以下切り捨て
p.floor
# => 3

#小数点以下切り上げ
p.ceil
# => 4
0
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
0
0