필터 지우기
필터 지우기

format long addition problem

조회 수: 1 (최근 30일)
AR
AR 2013년 4월 1일
with format long
7.5e-6+1e-7
ans =
7.600000000000000e-06
>> 7.6e-6+1e-7
ans =
7.700000000000001e-06
**why not 7.6e-6+1e-7
ans = 7.700000000000000e-06**
and how can i avoid this 0.000000000000001e-06???

답변 (1개)

Walter Roberson
Walter Roberson 2013년 4월 1일
  댓글 수: 2
AR
AR 2013년 4월 1일
편집: Walter Roberson 2013년 4월 1일
how can i convert 7.700000000000001e-06 to 7.7e-06????
Walter Roberson
Walter Roberson 2013년 4월 1일
You can use the symbolic toolbox, or you can use the fixed-point toolbox, or you can write your own Class for decimal arithmetic, or you can use a totally different tool that already implements decimal arithmetic.
There is no exact representation for 7.7e-06 in IEEE 754 binary floating point such as is used by MATLAB (and which is an international standard for numeric representation.) The closest you can get is
7.70000000000000081623076353398715809817076660692691802978515625e-06

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by