登录论坛

查看完整版本 : MATLAB舍入函数-如何向上或向下舍入.5?


poster
2019-12-10, 20:48
MATLAB的舍入函数如何与.5一起使用?像5.5吗?是四舍五入还是四舍五入?讨论此功能的Mathworks页面对此一无所获,该示例也无济于事!

这是MATLAB round函数的mathworks页面:

mathworks圆形函数页面 (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/round.html)



回答:

维基百科 (http://en.wikipedia.org/wiki/MATLAB#Variables)知道:

round(X):四舍五入到最接近的整数,后跟5个舍入到最接近0的整数 。例如,round(2.5)返回3; round(-2.5)返回-3。

关于舍入 (http://en.wikipedia.org/wiki/Rounding)的文章中有关于此方案的更多信息(从零舍入 (http://en.wikipedia.org/wiki/Rounding)一半),还有许多其他信息。



更多&回答... (https://stackoverflow.com/questions/3597197)