pow (マクロ)
パッケージ: CURL.LANGUAGE.COMPILER

指数で累乗された値を計算します。

シグネチャ

{pow base, exponent}:result
base: 整数、浮動小数点、数量値として評価される式です。
exponent: 整数または浮動小数点値として評価される式。

戻り値

exponent に累乗にされた base の値を返します。

base が数量の場合、結果もまた数量になります (指数が 0 の場合を除き)。

結果は、double の精度を持ちます。ただし、float 精度引数が最低 1 つ存在し、double 精度引数がない場合、結果は float の精度を持つことになります。

説明

負の base を整数以外の exponent に累乗すると、nan になります。

base が数量の場合、表現可能な数量を作成するため、exponentbase の単位と組み合わせることのできる単位でなくてはなりません。そうでない場合、例外が発生します。


例: pow を各種の値と共に使用
{text
    {br} 3 to the power of 2 is {pow 3, 2}
    {br} 2 to the power of 3 is {pow 2, 3}
    {br} 2 to the power of -3.5 is {pow 2, -3.5}
    {br} -2 to the power of 3 is {pow -2, 3}
    {br} -2 to the power of -3 is {pow -2, -3}
    {br} -2 to the power of -3.5 is {pow 2, -3.5}
    {br} 12m to the power of 3 is {pow 12m, 3}
    {br} 12(m^2) to the power of -2 is {pow 12(m^2), -2}
    {br} 6(m*s^-1) to the power of 0 is {pow 6(m*s^-1), 0}
    {br} The cube root of 27(m^3) is {pow 27(m^3), 1.0/3.0}
}