说明:值域为(-π/2,+π/2)。
举例
#include<stdio.h>
#include <math.h>
int main()
{
float x,y;
x=0.064;
y=0.2;
printf("atan2(%.3f,%.2f)=%.4f\n",y,x,atan2(y,x));
return 0;
}
Makefile文件:
<pre name="code" class="plain">CXX=g++
CFLAGS=-O3 -Wall -fmessage-length=0 -fPIC -DARCH_x86
OBJS=atan2.o
LIBS+=
TARGET= Tatan2
$(TARGET):$(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(CFLAGS) $(LIBS)
chmod 6755 $(TARGET)
all:$(TARGET)
install: all
chmod 6755 $(TARGET)
clean:
rm -f $(OBJS) $(TARGET)
运行结果:
[root@localhost atan2]# make
make: Warning: File `Makefile' has modification time 113 s in the future
cc -O3 -Wall -fmessage-length=0 -fPIC -DARCH_x86 -c -o atan2.o atan2.c
g++ -o Tatan2 atan2.o -O3 -Wall -fmessage-length=0 -fPIC -DARCH_x86
chmod 6755 Tatan2
make: warning: Clock skew detected. Your build may be incomplete.
[root@localhost atan2]# ./Tatan2
atan2(0.200,0.06)=1.2611