るりまサーチ

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

別のキーワード

  1. bigdecimal sqrt
  2. _builtin sqrt
  3. math sqrt
  4. bigdecimal/math sqrt
  5. bigmath sqrt

ライブラリ

クラス

検索結果

Integer.sqrt(n) -> Integer (18156.0)

非負整数 n の整数の平方根を返します。すなわち n の平方根以下の 最大の非負整数を返します。

...の整数の時に発生します。

//emlist[][ruby]{
Integer.sqrt(0) # => 0
Integer.sqrt(1) # => 1
Integer.sqrt(24) # => 4
Integer.sqrt(25) # => 5
Integer.sqrt(10**400) == 10**200 # => true
//}

Math.sqrt(n).floor と同等ですが、後者は浮動小数点数の精度...
...の限界によって
真の値とは違う結果になることがあります。

//emlist[][ruby]{
Integer.sqrt(10**46) #=> 100000000000000000000000
Math.sqrt(10**46).floor #=> 99999999999999991611392 (!)
//}


@see Math.#sqrt...