"Fixed point" binary sequence for values between 0 and 1

조회 수: 2 (최근 30일)
Duncan Bennett
Duncan Bennett 2021년 9월 12일
답변: Chunru 2021년 9월 12일
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.

답변 (1개)

Chunru
Chunru 2021년 9월 12일
% Given x in [0, 1)
x = 0.5234567
x = 0.5235
% Number of bits in binary (bits after .)
n = 32;
b = dec2bin(x*2.^n, n);
b=['0.' b]
b = '0.10000110000000010100001000011111'

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by