フィルターのクリア

How to calculate mantissa of 0.5

8 ビュー (過去 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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by