필터 지우기
필터 지우기

I noticed a difference with round() at 15 decimal places, and I need to know why this is so.

조회 수: 5 (최근 30일)
Yesterday, I noticed that
round(2.4999999999999999) %15 decimal places
ans =
3
But
round(2.499999999999999) %16 decimal places
ans =
2
This can be for any number, not just 2. Does anybody know what causes this?

채택된 답변

Mara Gati
Mara Gati 2016년 4월 16일
It's OK, I found the answer. Floating point doubles are precise to 15dp only.
  댓글 수: 1
John D'Errico
John D'Errico 2016년 4월 16일
It is not 15 decimal digits that matters, since doubles are not stored in decimal form. A double in MATLAB is actually stored in binary. So 52 binary bits represents something a little more accurate than 15 decimal digits.

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

추가 답변 (0개)

카테고리

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