首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::asin

Defined in header <cmath>

?

?

float asin( float arg );

(1)

?

double asin( double arg );

(2)

?

long double asin( long double arg );

(3)

?

double asin( Integral arg );

(4)

(since C++11)

的弧正弦的主值。arg...

4%29一组过载或接受任意参数的函数模板积分型等于2%29%28double29%。

参数

arg

-

value of a floating-point or Integral type

返回值

如果没有错误发生,则弧正弦arg范围内28弧辛%28 arg%29%29。[---

π

*。

;+

π

*。

),返回。

如果发生域错误,则返回支持%29的实现定义值%28 NaN。

如果由于下流而发生范围错误,则返回舍入%29后的正确结果%28。

错误处理

在以下情况下发生域错误arg超出范围[-1.0; 1.0]

如果实现支持ieee浮点算法%28IEC 60559%29,

  • 如果参数为±0,则返回
  • 如果arg>1,则会发生域错误并返回NaN。
  • 如果参数为nan,则返回nan。

二次

代码语言:javascript
复制
#include <cmath>
#include <iostream>
#include <cerrno>
#include <cfenv>
#include <cstring>
 
#pragma STDC FENV_ACCESS ON
int main()
{
    std::cout << "asin(1.0) = " << asin(1) << '\n'
              << "2*asin(1.0) = " << 2*asin(1) << '\n'
              << "asin(-0.5) = " << asin(-0.5) << '\n'
              << "6*asin(-0.5) =" << 6*asin(-0.5) << '\n';
    // special values
    std::cout << "asin(0.0) = " << asin(0) << " asin(-0.0)=" << asin(-0.0) << '\n';
    // error handling 
    errno = 0; std::feclearexcept(FE_ALL_EXCEPT);
    std::cout << "asin(1.1) = " << asin(1.1) << '\n';
    if(errno == EDOM)
        std::cout << "    errno == EDOM: " << std::strerror(errno) << '\n';
    if(std::fetestexcept(FE_INVALID))
        std::cout << "    FE_INVALID raised" << '\n';
}

二次

可能的产出:

二次

代码语言:javascript
复制
asin(1.0) = 1.5708
2*asin(1.0) = 3.14159
asin(-0.5) = -0.523599
6*asin(-0.5) = -3.14159
asin(0.0) = 0 asin(-0.0)=-0
asin(1.1) = nan
    errno == EDOM: Numerical argument out of domain
    FE_INVALID raised

二次

另见

acos

computes arc cosine (arccos(x)) (function)

atan

computes arc tangent (arctan(x)) (function)

atan2

arc tangent, using signs to determine quadrants (function)

sin

computes sine (sin(x)) (function)

asin(std::complex) (C++11)

computes arc sine of a complex number (arcsin(z)) (function template)

asin(std::valarray)

applies the function std::asin to each element of valarray (function template)

c关于asin的文件

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com