Dcimal to binary conversion of float numbers and vice-versa
2 ビュー (過去 30 日間)
古いコメントを表示
we are using this code to convert float values to binary...
B=-1.92
b=dec2bin(typecast(single(B),'uint32'),32)
but how do i convert it back to decimal...???
0 件のコメント
回答 (1 件)
Walter Roberson
2012 年 1 月 29 日
B = double( typecast(uint32(bin2dec(b)),'single') );
2 件のコメント
Walter Roberson
2012 年 1 月 30 日
Your output stored in "b" is output from dec2bin(), which will always be characters 0 and 1. Those characters are then sent to bin2dec, where they *will* be characters 0 and 1.
The code is correct for what the functionality you asked, to convert the dec2bin output back. If you are getting the error you quote, then that is not what you are trying to do.
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!