asin(x)函数详解

首页 / C++入门教程 / asin(x)函数详解

该函数计算以弧度表示的数字的反正弦值。

asin(x) = sin-1x

asin - 语法

假设数字是“ x”。语法为:

float asin(float x);
double asin(double x);
long double asin(long double x);
double asin(integral x);

Note: 如果传递的值是整数类型,则将其强制转换为double。

asin - 参数

x :要计算其反正弦值的值

asin - 返回值

参数 返回值
-1≤x≤1 -∏/2,∏/2
x1 Not a Number

asin - 例子1

让我们看一个简单的例子,当x的值为零时。

#include <iostream>  
#include<math.h>  
using namespace std;  
int main()  
{  
    float degree=0;  
    float x=degree*3.14/180;  
    std::cout << "Value of Sine is :" <<sin(x)<< std::endl;  
    cout<<"Inverse of Sine is :"<<asin(x);  
    return 0;  
}  

输出:

Value of Sine is :0
Inverse of Sine is :0   

在此示例中,当x的值为零时,asin()函数计算数字的反正弦值。

asin - 例子2

让我们看一个简单的示例,当x的值大于1时。

#include <iostream>  
#include<math.h>  
using namespace std;  
int main()  
{  
    float degree=90;  
    float x=degree*3.14/180;  
    std::cout << "Value of Sine is :" <<sin(x)<< std::endl;  
    cout<<"Inverse of Sine is :"<<asin(x);  
    return 0;  
}  

输出:

Value of Sine is :1
Inverse of Sine is :nan   

在此示例中,当x的值大于1时,asin()函数计算数字的反正弦值。

asin - 例子3

让我们看一个简单的例子,当x的值小于-1时。

#include <iostream>  
#include<math.h>  
using namespace std;  
int main()  
{  
    float degree= -78;  
    float x=degree*3.14/180;  
    std::cout << "Value of Sine is : " <<sin(x)<< std::endl;  
    cout<<"Inverse of Sine is :"<<asin(x);  
    return 0;  
}  

输出:

Value of Sine is : -0.978004
Inverse of Sine is :nan   

在此示例中,当x的值小于-1时,asin()函数计算数字的反正弦值。

链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-asin-function.html

来源:LearnFk无涯教程网

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

深入浅出gRPC -〔李林锋〕

快速上手Kotlin开发 -〔张涛〕

Java性能调优实战 -〔刘超〕

Netty源码剖析与实战 -〔傅健〕

设计模式之美 -〔王争〕

操作系统实战45讲 -〔彭东〕

HarmonyOS快速入门与实战 -〔QCon+案例研习社〕

李智慧 · 高并发架构实战课 -〔李智慧〕

徐昊 · TDD项目实战70讲 -〔徐昊〕

好记忆不如烂笔头。留下您的足迹吧 :)