1. 程式人生 > >vs2010 未定義的識別符號“round”

vs2010 未定義的識別符號“round”

今天,在vs2010裡使用round()函式進行四捨五入,添加了#include <math.h>標頭檔案,還報錯:

“round”: 找不到識別符號。

進math.h檔案檢視,原來vs2010的math裡沒有round,ceil()和floor()都有:


要使用的話,自己新增一個:

double round(double r)
{
	return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}