14件ヒット
[1-14件を表示]
(0.032秒)
ライブラリ
- ビルトイン (12)
- bigdecimal (2)
クラス
- BigDecimal (2)
- Float (1)
- Integer (6)
- Numeric (5)
検索結果
先頭5件
-
Numeric
# modulo(other) -> Numeric (108793.0) -
self を other で割った余り r を返します。
...す。
@param other 自身を割る数を指定します。
//emlist[例][ruby]{
p 13.modulo(4) #=> 1
p (11.5).modulo(3.5) #=> 1.0
p 13.modulo(-4) #=> -3
p (-13).modulo(4) #=> 3
p (-13).modulo(-4) #=> -1
p (-11).modulo(3.5) #=> 3.0
//}
@see Numeric#divmod, Numeric#remainder... -
Numeric
# %(other) -> Numeric (63493.0) -
self を other で割った余り r を返します。
...す。
@param other 自身を割る数を指定します。
//emlist[例][ruby]{
p 13.modulo(4) #=> 1
p (11.5).modulo(3.5) #=> 1.0
p 13.modulo(-4) #=> -3
p (-13).modulo(4) #=> 3
p (-13).modulo(-4) #=> -1
p (-11).modulo(3.5) #=> 3.0
//}
@see Numeric#divmod, Numeric#remainder... -
Numeric
# divmod(other) -> [Numeric] (63415.0) -
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にして返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。
...ています。
@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
# remainder(other) -> Numeric (63361.0) -
self を other で割った余り r を返します。
self を other で割った余り r を返します。
ここで、商 q と余り r は、
* self == other * q + r
と
* self > 0 のとき 0 <= r < |other|
* self < 0 のとき -|other| < r <= 0
* q は整数
をみたす数です。r の符号は self と同じになります。
商 q を直接返すメソッドはありません。self.quo(other).truncate がそれに相当します。
@param other 自身を割る数を指定します。
//emlist[例][ruby]{
p 13.... -
Numeric
# div(other) -> Integer (63040.0) -
self を other で割った整数の商 q を返します。
...メソッド / を呼びだし、floorを取ることで計算されます。
メソッド / の定義はサブクラスごとの定義を用います。
@param other 自身を割る数を指定します。
//emlist[例][ruby]{
p 3.div(2) # => 1
p (-3).div(2) # => -2
p (-3.0).div(2) # => -2
//}... -
Integer
# modulo(other) -> Numeric (45613.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
//emlist[][ruby]{
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
//}
@param other 二項演算の右側の引数(対象)
@return 計算結果 -
BigDecimal
# modulo(n) -> BigDecimal (45343.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 と同じ符号になります。これは BigDecimal#remainder とは
異なる点に注意してください。詳細は Numeric#%、
Numeric#re... -
Float
# divmod(other) -> [Numeric] (361.0) -
self を other で割った商 q と余り r を、 [q, r] という 2 要素の配列にして返します。 商 q は常に整数ですが、余り r は整数であるとは限りません。
...ます。
@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... -
Integer
# remainder(other) -> Numeric (361.0) -
self を other で割った余り r を返します。
self を other で割った余り r を返します。
r の符号は self と同じになります。
@param other self を割る数。
//emlist[][ruby]{
5.remainder(3) # => 2
-5.remainder(3) # => -2
5.remainder(-3) # => 2
-5.remainder(-3) # => -2
-1234567890987654321.remainder(13731) # => -6966
-1234567890987654321.remainder(13731.24) #... -
Integer
# **(other) -> Numeric (349.0) -
算術演算子。冪(べき乗)を計算します。
算術演算子。冪(べき乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
... -
Integer
# pow(other) -> Numeric (349.0) -
算術演算子。冪(べき乗)を計算します。
算術演算子。冪(べき乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
... -
Integer
# pow(other , modulo) -> Integer (349.0) -
算術演算子。冪(べき乗)を計算します。
算術演算子。冪(べき乗)を計算します。
@param other 二項演算の右側の引数(対象)
@param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@return 計算結果
@raise TypeError 2引数 pow で Integer 以外を指定した場合に発生します。
@raise RangeError 2引数 pow で other に負の数を指定した場合に発生します。
//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
... -
Integer
# %(other) -> Numeric (313.0) -
算術演算子。剰余を計算します。
算術演算子。剰余を計算します。
//emlist[][ruby]{
13 % 4 # => 1
13 % -4 # => -3
-13 % 4 # => 3
-13 % -4 # => -1
//}
@param other 二項演算の右側の引数(対象)
@return 計算結果 -
BigDecimal
# %(n) -> BigDecimal (43.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 と同じ符号になります。これは BigDecimal#remainder とは
異なる点に注意してください。詳細は Numeric#%、
Numeric#re...