157件ヒット
[101-157件を表示]
(0.017秒)
別のキーワード
種類
- インスタンスメソッド (135)
- 文書 (11)
- クラス (11)
ライブラリ
- ビルトイン (124)
- bigdecimal (22)
クラス
- BigDecimal (22)
- Bignum (3)
- Float (11)
- Integer (44)
- Numeric (55)
検索結果
先頭5件
-
Numeric
# divmod(other) -> [Numeric] (34.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......とき: other < r <= 0
* q は整数
をみたす数です。
divmod が返す商は Numeric#div と同じです。
また余りは、Numeric#modulo と同じです。
このメソッドは、メソッド / と % によって定義されています。
@param other 自身を割る数を指定......します。
//emlist[例][ruby]{
11.divmod(3) #=> [3, 2]
(11.5).divmod(3.5) #=> [3, 1.0]
11.divmod(-3) #=> [-4, -1]
11.divmod(3.5) #=> [3, 0.5]
(-11).divmod(3.5) #=> [-4, 3.0]
//}
@see Numeric#div, Numeric#modulo... -
Float
# divmod(other) -> [Numeric] (28.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 <=......ます。
@param other 自身を割る数を指定します。
//emlist[例][ruby]{
11.divmod(3) # => [3, 2]
(11.5).divmod(3.5) # => [3, 1.0]
11.divmod(-3) # => [-4, -1]
11.divmod(3.5) # => [3, 0.5]
(-11).divmod(3.5) # => [-4, 3.0]
//}
@see Numeric#div, Numeric#modulo... -
Numeric
# div(other) -> Integer (28.0) -
self を other で割った整数の商 q を返します。
...
self を other で割った整数の商 q を返します。
ここで、商 q と余り r は、それぞれ
* self == other * q + r
と
* other > 0 のとき: 0 <= r < other
* other < 0 のとき: other < r <= 0
* q は整数
をみたす数です。
商に対応する余りは......Numeric#modulo で求められます。
div はメソッド / を呼びだし、floorを取ることで計算されます。
メソッド / の定義はサブクラスごとの定義を用います。
@param other 自身を割る数を指定します。
//emlist[例][ruby]{
p 3.div(2) # => 1
p (... -
BigDecimal
# %(n) -> BigDecimal (23.0) -
self を n で割った余りを返します。
...
self を n で割った余りを返します。
@param n self を割る数を指定します。
//emlist[][ruby]{
require 'bigdecimal'
x = BigDecimal((2**100).to_s)
( x % 3).to_i # => 1
(-x % 3).to_i # => 2
( x % -3).to_i # => -2
(-x % -3).to_i # => -1
//}
戻り値は n と同じ符号にな... -
Integer
# **(other) -> Numeric (19.0) -
算術演算子。冪(べき乗)を計算します。
...子。冪(べき乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外... -
Integer
# pow(other) -> Numeric (19.0) -
算術演算子。冪(べき乗)を計算します。
...子。冪(べき乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外...