Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > cmathライブラリ > CMathモジュール > sqrt!

module function CMath.#sqrt!

sqrt!(x) -> Float

実数 x の平方根を返します。Math.#sqrt のエイリアスです。

[PARAM] x:
正の実数
[EXCEPTION] Math::DomainError:
x が負の数である場合に発生します。
[EXCEPTION] TypeError:
x に数値以外を指定した場合に発生します。
[EXCEPTION] RangeError:
x に実数以外の数値を指定した場合に発生します。

例:

require "cmath"
CMath.sqrt!(4.0) # => 2.0
CMath.sqrt!(9.0) # => 3.0

[SEE_ALSO] Math.#sqrt

module CMath