필터 지우기
필터 지우기

How to calculate mantissa of 0.5

조회 수: 7 (최근 30일)
Osamah Alayafi
Osamah Alayafi 2021년 9월 17일
댓글: Star Strider 2021년 9월 17일
Is there any function to calculate the mantissa of 0.8 by matlab?

채택된 답변

Star Strider
Star Strider 2021년 9월 17일
I created a little utility function to calculate the mantissa and exponent of a floating-point number a while ago, for my own use.
Trying it here —
expstr = @(x) [x(:).*10.^ceil(-log10(abs(x(:)+(x==0)))) floor(log10(abs(x(:)+(x==0))))];
expstr([0.5; 0.8])
ans = 2×2
5 -1 8 -1
The mantissa is the first element and the exponent is the second element in each row.
.
  댓글 수: 2
Osamah Alayafi
Osamah Alayafi 2021년 9월 17일
Thanks alot. If I understand you correctly, the mantissa of 0.5 is 5?
Star Strider
Star Strider 2021년 9월 17일
My pleasure!
Yes.
The exponent (in this instance) is -1.
.

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

추가 답변 (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