|
|
发表于 5-1-2010 11:39 AM
|
显示全部楼层
#include <math.h>
float round(float x);
int main(void){
float valL = 39.85;
float valS = 39.84;
round(valL);//you will get 39.9
round(valS);//you will get 39.8
return 0;
}
float round(float x){
float const shift = powf(10.0f,1);
return floorf(x*shift+0.5f)/shift;
} |
|