I can't figure out why the floor wont come to 1752?
>> 3.501/40*20*10^3+1.5
ans =
1.752000000000000e+003
>> floor(ans)
ans =
1751

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 9월 20일

0 개 추천

Rounding error caused by floating point calculation.
>> 3.501/40*20*10
ans =
17.504999999999995

댓글 수: 2

Jan
Jan 2011년 9월 20일
sprintf('%.13f', 3.501/40*20*10^3+1.5)
>> 1751.9999999999998
sprintf('%.12f', 3.501/40*20*10^3+1.5)
>> 1752.000000000000
Fangjun Jiang
Fangjun Jiang 2011년 9월 20일
Thanks, Jan! That's even better to explain the problem!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by