Could anyone tell me what is wrong with the following code?

조회 수: 1 (최근 30일)
Ryan
Ryan 2020년 6월 29일
댓글: Ryan 2020년 6월 29일
>> a=(6.6-5.5)/0.1
a =
11.0000
>> floor(a)
ans =
10
I suppose I should get ans=11, right? But I got ans=11. If I run the following code, I got the right result
>> a=(2.2-1.1)/0.1
a =
11
>> floor(a)
ans =
11
Could anyone tell me what is wrong with the first part?

채택된 답변

madhan ravi
madhan ravi 2020년 6월 29일
편집: madhan ravi 2020년 6월 29일
sprintf('%.32f',(6.6-5.5)/0.1)
(6.6-5.5)/sym(0.1)
  댓글 수: 1
Ryan
Ryan 2020년 6월 29일
>> sprintf('%.32f',(6.6-5.5)/sym(1))
ans =
'1.10000000000000008881784197001252'
Now I tried the above code, and I got the wrong result. Is it an inherent flaw in MATLAB, which cannot be fixed completely?

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by