std::hypot
提供: cppreference.com
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
Defined in header <cmath>
|
||
float hypot( float x, float y ); |
(1) | (C++11およびそれ以降) |
double hypot( double x, double y ); |
(2) | (C++11およびそれ以降) |
long double hypot( long double x, long double y ); |
(3) | (C++11およびそれ以降) |
Promoted hypot( Arithmetic x, Arithmetic y ); |
(4) | (C++11およびそれ以降) |
計算の中間段階での過度のオーバーフローまたはアンダーフローが発生することなく、
4) x
とy
の二乗和の平方根を計算します。これは、長さの辺をもつ直角三角形の斜辺の長さx
とy
、または起点(x,y)
、または複素数(0,0)
の大きさから点x+iy
の距離Original:
Computes the square root of the sum of the squares of
x
and y
, without undue overflow or underflow at intermediate stages of the computation. This is the length of the hypotenuse of a right-angled triangle with sides of length x
and y
, or the distance of the point (x,y)
from the origin (0,0)
, or the magnitude of a complex number x+iy
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
いずれかの引数が整数型を持つ場合、それはdoubleにキャストされます。他の引数はlong doubleあれば、戻り値の型はlong double、それ以外の場合はdoubleです.
Original:
If any argument has integral type, it is cast to double. If any other argument is long double, then the return type is long double, otherwise it is double.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] パラメータ
x | - | 浮動小数点値
Original: floating point value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
y | - | 浮動小数点値
Original: floating point value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集] 値を返します
直角三角形の斜辺、√x2
+y2
.
+y2
.
Original:
The hypotenuse of a right-angled triangle, √x2
+y2
.
+y2
.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例外
結果がオーバーフローした場合は、範囲エラーが発生する可能性があり、FE_OVERFLOWが発生する場合があります.
Original:
If the result overflows, a range error may occur and FE_OVERFLOW may be raised.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
結果が非正規の場合は、アンダーフローエラーが発生する可能性があり、FE_UNDERFLOWが発生する場合があります.
Original:
If the result is subnormal, an underflow error may occur and FE_UNDERFLOW may be raised.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] ノート
典型的な実装戦略はu√1+(
)2
の等価
v |
u |
の等価
u
ですstd::max(x,y)とv
std::min(x,y)です..を計算することであるOriginal:
Typical implementation strategy is to calculate an equivalent of u√1+(
)2
where
v |
u |
where
u
is std::max(x,y) and v
is std::min(x,y).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
このコードを実行します
#include <cmath> #include <utility> #include <iostream> std::pair<double, double> cartesian_to_polar(double x, double y) { return {std::hypot(x, y), std::atan2(y,x)}; } int main() { std::pair<double, double> polar = cartesian_to_polar(1, 1); std::cout << "(1,1) cartesian is (" << polar.first << "," << polar.second<< ") polar\n"; }
出力:
(1,1) cartesian is (1.41421,0.785398) polar
[編集] も参照してください
平方根は(√x)を計算します Original: computes square root (√x) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) | |
与えられた電力(xy)に番号を発生させます Original: raises a number to the given power (xy) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) | |
複素数の絶対値を返します Original: returns the magnitude of a complex number The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |