C语言,一个浮点数,怎么四舍五入保留到个位数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C语言,一个浮点数,怎么四舍五入保留到个位数相关的知识,希望对你有一定的参考价值。

int Function(float yournum)

int temp= yournum*10;
int floatPart=temp%10;
int intPart=temp/10;
if(floatPart>=5)

return intPart+1;

return intPart;
参考技术A Math

floor

~

以上是关于C语言,一个浮点数,怎么四舍五入保留到个位数的主要内容,如果未能解决你的问题,请参考以下文章