Streamlining of zeroing out last 2 bits of fixed 16 bit number?
Show older comments
Would setting correctly the parameters of quantizer object be the solution when the goal is to perform bit truncation of fixed 16 bit, to get left with 14 bit of significant bits, and 0s on last two bits?
I don't know the fraction length to be used, but we can suppose that the binary point is on the extreme left, since all numbers are <1. Tried something like this, just to get the same bit representation as with bitshifts:
q = quantizer('fixed','floor',[14 20]);
x_trunc= quantize(q, x)
Streamlining is needed to avoid for loops with eg. double bitshift:
bitshift(bitshift(fi(x, 1, 16), -2), 2))
so any solution is welcomed. Thank you
Accepted Answer
More Answers (1)
dpb
on 24 Oct 2023
I have no knowledge of how Fixed-Point Designer stores stuff, but can you not do something like
x=bitand(x,0xFFFC)
?
2 Comments
Imola Fodor
on 24 Oct 2023
dpb
on 24 Oct 2023
In that arena I've no knowledge; never used FP TB...
Categories
Find more on Cast and Quantize Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!