るりまサーチ

最速Rubyリファレンスマニュアル検索!
35件ヒット [1-35件を表示] (0.015秒)
トップページ > クエリ:**[x] > クエリ:sqrt[x]

別のキーワード

  1. _builtin **
  2. matrix **
  3. bigdecimal **
  4. rational **
  5. bn **

ライブラリ

クラス

モジュール

キーワード

検索結果

Integer.sqrt(n) -> Integer (18179.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...

Complex#abs -> Numeric (18.0)

自身の絶対値を返します。

...自身の絶対値を返します。

以下の計算の結果を Float オブジェクトで返します。

sqrt
(self.real ** 2 + self.imag ** 2)

//emlist[例][ruby]{
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.70710678118...

Complex#magnitude -> Numeric (18.0)

自身の絶対値を返します。

...自身の絶対値を返します。

以下の計算の結果を Float オブジェクトで返します。

sqrt
(self.real ** 2 + self.imag ** 2)

//emlist[例][ruby]{
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.70710678118...

CMath.#exp!(x) -> Float (12.0)

実数 x の指数関数(Math::E の x 乗)の値を返します。 Math.#exp のエイリアスです。

...た場合に発生します。

@raise RangeError x に実数以外の数値を指定した場合に発生します。

//emlist[例][ruby]{
require "cmath"
CMath.exp!(0) # => 1
CMath.exp!(0.5) # => Math.sqrt(Math::E)
CMath.exp!(1) # => Math::E
CMath.exp!(2) # => Math::E ** 2
//}

@see Math.#exp...