MATLAB舍入函数-如何向上或向下舍入.5? [英] MATLAB round function - how does it round .5 up or down?

查看:132
本文介绍了MATLAB舍入函数-如何向上或向下舍入.5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How does MATLAB's round function work with .5? Like 5.5? Does it round up to 6, or round down to 5? The Mathworks page talking about this function says nothing about this, and the example doesn't help either!

这是MATLAB圆形函数的mathworks页面:

Here is the mathworks page for the MATLAB round function:

​​ mathworks round函数页面

推荐答案

维基百科知道:

四舍五入(X):四舍五入到最接近的整数, 拖至最近的5个轮 远离零的整数.例如, round(2.5)返回3;圆(-2.5) 返回-3.

round(X): round to nearest integer, trailing 5 rounds to the nearest integer away from zero. For example, round(2.5) returns 3; round(-2.5) returns -3.

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆