関連するキーワード
検索結果
先頭5件
-
Numeric
# truncate -> Integer (18126) -
自身と 0 との間にある整数で、自身にもっとも近い整数を返します。
...整数で、自身にもっとも近い整数を返します。
1.truncate #=> 1
1.2.truncate #=> 1
(-1.2).truncate #=> -1
(-1.5).truncate #=> -1
@see Numeric#ceil, Numeric#floor, Numeric#round... -
Numeric
# ceil -> Integer (7) -
自身と等しいかより大きな整数のうち最小のものを返します。
...を返します。
1.ceil #=> 1
1.2.ceil #=> 2
(-1.2).ceil #=> -1
(-1.5).ceil #=> -1
@see Numeric#floor, Numeric#round, Numeric#truncate... -
Numeric
# floor -> Integer (7) -
自身と等しいかより小さな整数のうち最大のものを返します。
...します。
1.floor #=> 1
1.2.floor #=> 1
(-1.2).floor #=> -2
(-1.5).floor #=> -2
@see Numeric#ceil, Numeric#round, Numeric#truncate... -
Numeric
# remainder(other) -> Numeric (7) -
self を other で割った余り r を返します。
...をみたす数です。r の符号は self と同じになります。
商 q を直接返すメソッドはありません。self.quo(other).truncate がそれに相当します。
@param other 自身を割る数を指定します。
p 13.remainder(4) #=> 1
p (11.5).remainder(3.5) #=......> 1.0
p 13.remainder(-4) #=> 1
p (-13).remainder(4) #=> -1
p (-13).remainder(-4) #=> -1
p (-11).remainder(3.5) #=> -0.5
@see Numeric#divmod, Numeric#modulo... -
Numeric
# round -> Integer (7) -
自身ともっとも近い整数を返します。
...値 0.5, -0.5 はそれぞれ 1,-1 に切り上げされます。いわゆる四捨五入ですが、偶数丸めではありません。
1.round #=> 1
1.2.round #=> 1
(-1.2).round #=> -1
(-1.5).round #=> -2
@see Numeric#ceil, Numeric#floor, Numeric#truncate...
