#include"../common.h"
#include <math.h>
int main()
{
double azimuth = 13192148992.0 * 4 + 320.0;
int x = 360;
azimuth = azimuth - floor(azimuth/x)*x;
printf("azimuth = %f\n",azimuth);
float azimuth2 = 13192148992.0 * 4 + 320.0;
int x2 = 360;
azimuth2 = azimuth2 - floor(azimuth2/x2)*x2;
printf("azimuth2 = %f\n",azimuth2);
}
要注意的是,floor返回的是double,如果原本的数据值不是double类型,且数据长度超过float,就会有问题。
结果如下:
azimuth = 48.000000
azimuth2 = -2432.000000