54件ヒット
[1-54件を表示]
(0.043秒)
別のキーワード
検索結果
先頭5件
-
Rational
# quo(other) -> Rational | Float (36223.0) -
商を計算します。
...//emlist[例][ruby]{
r = Rational(3, 4)
r / 2 # => (3/8)
r / 2.0 # => 0.375
r / 0.5 # => 1.5
r / Rational(1, 2) # => (3/2)
r / 0 # => ZeroDivisionError
//}
@raise ZeroDivisionError other が 0 の時に発生します。
@see Numeric#quo... -
Rational
# / (other) -> Rational | Float (21123.0) -
商を計算します。
...//emlist[例][ruby]{
r = Rational(3, 4)
r / 2 # => (3/8)
r / 2.0 # => 0.375
r / 0.5 # => 1.5
r / Rational(1, 2) # => (3/2)
r / 0 # => ZeroDivisionError
//}
@raise ZeroDivisionError other が 0 の時に発生します。
@see Numeric#quo... -
Numeric
# quo(other) -> Rational | Float | Complex (18252.0) -
self を other で割った商を返します。 整商を得たい場合は Numeric#div を使ってください。
...。
Numeric#fdiv が結果を Float で返すメソッドなのに対して quo はなるべく正確な数値を返すことを意図しています。
具体的には有理数の範囲に収まる計算では Rational の値を返します。
Float や Complex が関わるときはそれらのク......am other 自身を割る数を指定します。
//emlist[例][ruby]{
1.quo(3) #=> (1/3)
1.0.quo(3) #=> 0.3333333333333333
1.quo(3.0) #=> 0.3333333333333333
1.quo(0.5) #=> 2.0
Complex(1, 1).quo(1) #=> ((1/1)+(1/1)*i)
1.quo(Complex(1, 1)) #=> ((1/2)-(1/2)*i)
//}
@see Numeric#fdiv... -
Numeric (98.0)
-
数値を表す抽象クラスです。Integer や Float などの数値クラス は Numeric のサブクラスとして実装されています。
...。
=> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Numeric Integer Fixnum Bignum Float Rational Complex
-------------------------------------------------------------------------------------------
% |......- o o o - -
Numeric Integer Fixnum Bignum Float Rational Complex
-------------------------------------------------------------------------------------------
<< |......- o o - - -
Numeric Integer Fixnum Bignum Float Rational Complex
-------------------------------------------------------------------------------------------
abs |......てください。
=> ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin15]
Numeric Integer Float Rational Complex
--------------------------------------------------------------------------------
% | o o......o
< | - o o - -
Numeric Integer Float Rational Complex
--------------------------------------------------------------------------------
<< | - o......-
^ | - o - - -
Numeric Integer Float Rational Complex
--------------------------------------------------------------------------------
abs | o o... -
Integer
# / (other) -> Numeric (20.0) -
除算の算術演算子。
...other が Float、Rational、Complex の場合、普通の商を other と
同じクラスのインスタンスで返します。
@param other 二項演算の右側の引数(対象)
@return 計算結果
//emlist[例][ruby]{
7 / 2 # => 3
7 / -2 # => -4
7 / 2.0 # => 3.5
7 / Rational(2, 1) # => (7/2)......7 / Complex(2, 0) # => ((7/2)+0i)
begin
2 / 0
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end
//}
@see Integer#div, Integer#fdiv, Numeric#quo...