6件ヒット
[1-6件を表示]
(0.127秒)
検索結果
先頭5件
-
Float
# numerator -> Integer (18307.0) -
自身を Rational に変換した時の分子を返します。
...自身を Rational に変換した時の分子を返します。
@return 分子を返します。
//emlist[例][ruby]{
2.0.numerator # => 2
0.5.numerator # => 1
//}
@see Float#denominator... -
Float
# round(ndigits = 0) -> Integer | Float (18307.0) -
自身ともっとも近い整数もしくは実数を返します。
...3.141592653589793
t.round(3) # => 3.142
t.round(0) # => 3
t.round(1) # => 3.1
t = t**10 # => 93648.04747608298
t.round(-0) # => 93648
t.round(-1) # => 93650
t.round(-2) # => 93600
t.round(-3) # => 94000
t.round(-100) # => 0
//}
@see Float#ceil, Float#floor, Float#truncate... -
Float
# magnitude -> Float (9307.0) -
自身の絶対値を返します。
自身の絶対値を返します。
//emlist[例][ruby]{
34.56.abs # => 34.56
-34.56.abs # => 34.56
//} -
Float
# modulo(other) -> Float (9307.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
@param other 二項演算の右側の引数(対象)
//emlist[例][ruby]{
# 剰余
3.0 % 1.2 # => 0.6000000000000001
3.0 % 0.0 # ZeroDivisionError
//} -
Float
# truncate -> Integer (9307.0) -
小数点以下を切り捨てて値を整数に変換します。
小数点以下を切り捨てて値を整数に変換します。
//emlist[例][ruby]{
2.8.truncate # => 2
(-2.8).truncate # => -2
//}
@see Numeric#round, Numeric#ceil, Numeric#floor -
Float
# divmod(other) -> [Numeric] (307.0) -
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にして返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。
self を other で割った商 q と余り r を、
[q, r] という 2 要素の配列にして返します。
商 q は常に整数ですが、余り r は整数であるとは限りません。
ここで、商 q と余り r は、
* self == other * q + r
と
* other > 0 のとき: 0 <= r < other
* other < 0 のとき: other < r <= 0
* q は整数
をみたす数です。
このメソッドは、メソッド / と % によって定義されています。
@param other 自身を割る数を指定します。
//emli...