Decimal floating to binary

Hi, I need to convert 1x10^50 decimal floating point to 32 bit binary.
The mantissa is 24 bit and the exponent is 8 bit.
Exponent has a bias of 127 instead of a sign bit.
To try the program with several other numbers including 1x10^30 and 1x10^-50
Thank you.

2 件のコメント

Jan
Jan 2017 年 1 月 26 日
What have you tried so far and what is your question?
James Tursa
James Tursa 2017 年 1 月 26 日
Is the leading mantissa bit hidden or present? Do you want the result as a bit pattern contained in e.g. a uint32? Or do you just want the result in a char string of 1's and 0's for you to examine?

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 1 月 26 日

0 投票

1E50 cannot be represented by that scheme. The maximum that can be represented with an 8 bit exponent with bias 128 is 2^127 which is about 1e38. The smallest would be about 1 over that, divided by 2 (you can get one division further because of the -128 vs +127)
You would need a bias of 167 to represent 1E50

カテゴリ

ヘルプ センター および File ExchangeNumeric Types についてさらに検索

質問済み:

2017 年 1 月 26 日

回答済み:

2017 年 1 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by