るりまサーチ (Ruby 2.6.0)

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

別のキーワード

  1. _builtin zerodivisionerror
  2. zerodivisionerror
  3. zerodivisionerror _builtin

クラス

キーワード

検索結果

ZeroDivisionError (114007.0)

整数に対して整数の 0 で除算を行ったときに発生します。

整数に対して整数の 0 で除算を行ったときに発生します。

Integer#div(other) -> Integer (43.0)

整商(整数の商)を返します。 普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

整商(整数の商)を返します。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

other が Integer オブジェクトの場合、Integer#/ の結果と一致します。

div に対応する剰余メソッドは modulo です。

@param other 二項演算の右側の引数(対象)
@return 計算結果

//emlist[例][ruby]{
7.div(2) # => 3
7.div(-2) # => -4
7.div(2.0) # => 3
7.div(Rational(2, 1)) # => 3

begin
2.div(0)
rescue => ...

Rational#/(other) -> Rational | Float (43.0)

商を計算します。

商を計算します。

@param other 自身を割る数

other に Float を指定した場合は、計算結果を Float で返します。

//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 ZeroD...

Rational#quo(other) -> Rational | Float (43.0)

商を計算します。

商を計算します。

@param other 自身を割る数

other に Float を指定した場合は、計算結果を Float で返します。

//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 ZeroD...

Float#%(other) -> Float (25.0)

算術演算子。剰余を計算します。

算術演算子。剰余を計算します。

@param other 二項演算の右側の引数(対象)

//emlist[例][ruby]{
# 剰余
3.0 % 1.2 # => 0.6000000000000001
3.0 % 0.0 # ZeroDivisionError
//}

絞り込み条件を変える

Float#modulo(other) -> Float (25.0)

算術演算子。剰余を計算します。

算術演算子。剰余を計算します。

@param other 二項演算の右側の引数(対象)

//emlist[例][ruby]{
# 剰余
3.0 % 1.2 # => 0.6000000000000001
3.0 % 0.0 # ZeroDivisionError
//}

Integer#/(other) -> Numeric (25.0)

除算の算術演算子。

除算の算術演算子。

other が Integer の場合、整商(整数の商)を Integer で返します。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

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...

TracePoint (25.0)

Kernel.#set_trace_func と同様の機能をオブジェクト指向的な API で 提供するクラスです。

Kernel.#set_trace_func と同様の機能をオブジェクト指向的な API で
提供するクラスです。

//emlist[例:例外に関する情報を収集する][ruby]{
trace = TracePoint.new(:raise) do |tp|
p [tp.lineno, tp.event, tp.raised_exception]
end
# => #<TracePoint:0x007f786a452448>

trace.enable
# => false

0 / 0
# => [5, :raise, #<ZeroDivisionError: divided by 0...

TracePoint#raised_exception -> Exception (25.0)

発生した例外を返します。

発生した例外を返します。

@raise RuntimeError :raise イベントのためのイベントフックの外側で実行し
た場合に発生します。

//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided by 0>
end
trace.enable
begin
0/0
rescue
end
//}