'Decimal Fixed Point Scaling' To 'Binary Fixed Point Scaling' Conversion

4 ビュー (過去 30 日間)
Sachin Ganjare
Sachin Ganjare 2014 年 8 月 21 日
回答済み: Iain 2014 年 8 月 21 日
How to do 'Decimal Fixed Point Scaling' To 'Binary Fixed Point Scaling' Conversion?
Eg;
Phyzical value of x = 10.7
'x' is scaled with factor of '0.1', so value of x becomes: x = 107
Now, I want to convert this value(x = 107) to binary fixed point, ensuring that there is no loss in conversion.
Please help!!

回答 (1 件)

Iain
Iain 2014 年 8 月 21 日
floating = 10.72; % this is a floating point value (32 or 64 bit value)
scaled = floating * 10; %floating point value (32 or 64 bit value)
integerised = round(scaled); % floating point value holding an integer (32 or 64 bit value)
integer = uint8(integerised); % 8 bit, unsigned, integer value.
binary = dec2bin(integerised); % A string containing a sequence of 1s and 0s. eg '1011'

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by