How to round the decimal values?

1 次查看(过去 30 天)
Ahmed Roshbik
Ahmed Roshbik 2020-3-10
Hello
i have a project and i cant round up the value 0.7954 to the value 0.796, can someone help me?
Thank you.
  2 个评论
Walter Roberson
Walter Roberson 2020-3-10
Why would it round up? To 3 decimal places it is closer to 0.795
Ahmed Roshbik
Ahmed Roshbik 2020-3-10
i know it does that already but the rest of calculations depends on the value being 0.796

请先登录,再进行评论。

回答(1 个)

Adam
Adam 2020-3-10
编辑:Adam 2020-3-10
ceil( 0.7954 * 1000 ) / 1000
It should also be noted though that many seemingly 'round' decimal numbers cannot be perfectly represented in floating point so that you likely will not have precisely 0.796 as your final answer.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by