るりまサーチ

最速Rubyリファレンスマニュアル検索!
23件ヒット [1-23件を表示] (0.049秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

検索結果

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

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

...

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 => e
e # => #<ZeroDivisionError: div...
...ided by 0>
end


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

//}

@
see Integer#fdiv, Integer#/, Integer#modulo...

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

除算の算術演算子。

...す。

@
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 Int...
...eger#div, Integer#fdiv, Numeric#quo...