how to convert 2 double number and packed in 32 bit
22 views (last 30 days)
Show older comments
hi i want to convert 2 double number 0.5 and -0.5 in 16 bit and packed into 32 bit. each number in double takes 8 bytes. i want to convert in this number in fixed point 16,14 (2 bytes). and finally i want to packed these 2 number in 32 bit(4 bytes). please tell me how i can do this operation in matlab
2 Comments
Walter Roberson
on 21 Aug 2015
Does 16,14 indicate 1 sign bit, then 1 bit of integer, then 14 bits of fraction? Or do you want to use 2s complement?
Answers (1)
Walter Roberson
on 21 Aug 2015
Edited: Walter Roberson
on 21 Aug 2015
typecast(int16(x*2^14),'uint32')
is one possibility depending on what you mean by 16,14
3 Comments
Walter Roberson
on 24 Aug 2015
typecast(storedInteger([FirstFi, SecondFi]),'uint32')
or you might need
typecast([storedInteger(FirstFi), storedInteger(SecondFi)], 'uint32')
See Also
Categories
Find more on Data Type Conversion 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!