"Fixed point" binary sequence for values between 0 and 1
3 次查看(过去 30 天)
显示 更早的评论
I want to express the values between 0 and 1 as binary sequences of the form
Currently, I've been converting my float to the IEEE bits and extracting the fractional part. However, this requires me to analyze the exponential part to see how many "0 placeholders" I need to add in.
Is there a way to go from float to fixed point binary sequence?
Forgive me if any terminology is confusing, I am just beginning to study CS stuff.
0 个评论
回答(1 个)
Chunru
2021-9-12
% Given x in [0, 1)
x = 0.5234567
% Number of bits in binary (bits after .)
n = 32;
b = dec2bin(x*2.^n, n);
b=['0.' b]
0 个评论
另请参阅
类别
在 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!