るりまサーチ

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

別のキーワード

  1. _builtin zerodivisionerror
  2. zerodivisionerror
  3. zerodivisionerror _builtin

クラス

キーワード

検索結果

ZeroDivisionError (38002.0)

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

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

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

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

...v(-2) # => -4
7.div(2.0) # => 3
7.div(Rational(2, 1)) # => 3

begin
2.div(0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
end

begin
2.div(0.0)
rescue => e
e # => #<ZeroDivisionError: divided by 0>
# Integer#/ と違い、引数が Float でもゼロで割ることはできない...

Rational#/(other) -> Rational | Float (14.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#quo(other) -> Rational | Float (14.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...

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

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

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

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

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

絞り込み条件を変える

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

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

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

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

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

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

除算の算術演算子。

...側の引数(対象)
@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...

TracePoint (8.0)

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

...tp|
p [tp.lineno, tp.event, tp.raised_exception]
end
# => #<TracePoint:0x007f786a452448>

trace.enable
# => false

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

TracePoint.new または、TracePoint.trace で指定したブロック
は、メソッドの引数(上記の例では...

TracePoint#raised_exception -> Exception (8.0)

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

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

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