MATLAB Answers

How to round the decimal values?

조회 수: 2(최근 30일)
Ahmed Roshbik
Ahmed Roshbik 10 Mar 2020
댓글: Ahmed Roshbik 10 Mar 2020
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 10 Mar 2020
Why would it round up? To 3 decimal places it is closer to 0.795
Ahmed Roshbik
Ahmed Roshbik 10 Mar 2020
i know it does that already but the rest of calculations depends on the value being 0.796

댓글을 달려면 로그인하십시오.


Adam 10 Mar 2020
편집: Adam 10 Mar 2020
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.

  댓글 수: 1

Ahmed Roshbik
Ahmed Roshbik 10 Mar 2020
it didn't round up to 0.796 it still reads 0.795

댓글을 달려면 로그인하십시오.


Community Treasure Hunt

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

Start Hunting!

Translated by