question concerning rounding of numbers
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi
I am having trouble rounding a number to a fixed number of digits. Can anyone explain the problem I am encountering? (As shown in this figure)
댓글 수: 0
채택된 답변
James Tursa
2015년 3월 26일
댓글 수: 1
John D'Errico
2015년 3월 26일
As has been said, no matter how hard you try, you cannot represent 30.7 exactly as a double precision number. That is a binary representation, and your number is not exactly representable.
In fact, this is true of almost all the numbers you will write in decimal form. The exceptions are integers of a reasonable size, and those numbers that can be written as sums of limited negative powers of 2. So 0.5, and 0.375 will be exactly represented.
추가 답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!