るりまサーチ

最速Rubyリファレンスマニュアル検索!
9件ヒット [1-9件を表示] (0.003秒)
トップページ > クラス:Integer[x] > ライブラリ:rational[x]

キーワード

検索結果

Integer#**(other) -> Rational | Float | Integer (3)

冪(べき)乗を計算します。

...数(Integer)ならば、整数(Integer)を返す。
* otherが負の整数(Integer)ならば、有理数(Rational)を返す。
* otherが有理数(Rational)や浮動小数(Float)ならば、浮動小数(Float)を返す。

例:

2 ** 3 #=> 8
2 ** -3 #=> Rational(1, 8...
...)
2 ** Rational(3) #=> 8.0
2 ** Rational(1, 2) #=> 1.4142135623731...

Integer#/(other) -> Rational | Float | Integer (3)

商を計算します。

...果は以下のようになります。

* otherが有理数(Rational)ならば、有理数(Rational)を返す。
* otherがそれ以外なら、Integer#/と同じ。つまり、
other が整数(Integer)ならば、整数(Integer)を(整除)、浮動小数(Float)ならば、
浮動小数...

Integer#denominator -> Integer (3)

分母(常に1)を返します。

...分母(常に1)を返します。

@return 分母を返します。

@see Integer#numerator...

Integer#gcd(n) -> Integer (3)

自身と整数 n の最大公約数を返します。

...# => 1
3.gcd(-7) # => 1
((1<<31)-1).gcd((1<<61)-1) # => 1

また、self や n が 0 だった場合は、0 ではない方の整数の絶対値を返します。

3.gcd(0) # => 3
0.gcd(-7) # => 7

@see Integer#lcm, Integer#gcdlcm...

Integer#gcdlcm(n) -> [Integer] (3)

自身と整数 n の最大公約数と最小公倍数の配列 [self.gcd(n), self.lcm(n)] を返します。

...以外のものを指定すると発生します。

例:

6.gcdlcm(9) # => [3, 18]
2.gcdlcm(2) # => [2, 2]
3.gcdlcm(-7) # => [1, 21]
((1<<31)-1).gcdlcm((1<<61)-1) # => [1, 4951760154835678088235319297]

@see Integer#gcd, Integer#lcm...

絞り込み条件を変える

Integer#lcm(n) -> Integer (3)

自身と整数 n の最小公倍数を返します。

...# => 2
3.lcm(-7) # => 21
((1<<31)-1).lcm((1<<61)-1) # => 4951760154835678088235319297

また、self や n が 0 だった場合は、0 を返します。

3.lcm(0) # => 0
0.lcm(-7) # => 0

@see Integer#gcd, Integer#gcdlcm...

Integer#numerator -> Integer (3)

分子(常に自身)を返します。

...分子(常に自身)を返します。

@return 分子を返します。

@see Integer#denominator...

Integer#power!(other) -> Integer | Float (3)

冪(べき)乗を計算します。

...冪(べき)乗を計算します。

@param other 自身を other 乗する数

rational
で再定義される前のInteger#**の別名です。
other が正または 0 の整数 (Integer) ならば、整数 (Integer) を、それ以外
なら、浮動小数 (Float) を返します。...

Integer#to_r -> Rational (3)

自身を Rational に変換します。

...自身を Rational に変換します。

例:

1.to_r # => Rational(1, 1)
(1<<64).to_r # => Rational(18446744073709551616, 1)...