how to round 10.5 to 10 ?

조회 수: 3 (최근 30일)
tomer polsky
tomer polsky 2018년 7월 3일
답변: Asit Kumar 2018년 7월 4일
hello I want to round down from 10.5 to 10 is there a command for this operation ?
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 7월 3일
Is the question about the rounding of values that end in 0.5 exactly, since round() typically rounds those up?

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

답변 (2개)

Stephen23
Stephen23 2018년 7월 3일
  댓글 수: 1
Stephen23
Stephen23 2018년 7월 3일
tomer polsky's "Answer" moved here:
thank you

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


Asit Kumar
Asit Kumar 2018년 7월 4일
both fix and floor will give the same answer for positive decimal numbers (if your intention is to round down regardless the decimal value)
But they will produce different results for negative decimals:
1. fix
fix rounds towards 0
fix(10.5) = 10
fix(-10.5) = -10
2. floor
floor rounds towards negative infinity
floor(10.5) = 10
floor(-10.5) = -11

카테고리

Help CenterFile Exchange에서 Signal Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by