How to set individual bits in 64-bit double-precision floating number

5 ビュー (過去 30 日間)
Kevin
Kevin 2018 年 5 月 4 日
コメント済み: Kevin 2018 年 5 月 5 日
Hi everyone,
I am wondering if it is possible to set individual bits in 64-bit double-precision floating number in MATLAB.
I know that I can use "format hex" to read the bits. But how can I set it?
Thanks Kevin

採用された回答

Walter Roberson
Walter Roberson 2018 年 5 月 5 日
Example:
typecast(bitset(typecast(pi,'uint64'),53,1),'double')
Bit numbering is 64 for the most significant bit, down to 1 for the least significant bit.
As the IEEE 754 floating point representation is being altered, the change I made here of effectively adding 1 to the exponent resulting in doubling the result (because IEEE 754 has binary representation, not decimal representation.)
  3 件のコメント
Walter Roberson
Walter Roberson 2018 年 5 月 5 日
I have never worked for CIBC or any finance company.
I find a record of Michael Robbins in comp.soft-sys.matlab who worked for CIBC. Looks like he had about 75-ish posts. My active time on comp.soft-sys.matlab did not overlap with him.
Kevin
Kevin 2018 年 5 月 5 日
You are correct. I was thinking about Michael Robbins.
Thanks again for your help.

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

その他の回答 (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