convert negative integer to n (>32) bits?

1 次查看(过去 30 天)
Qinghua
Qinghua 2011-12-20
I need convert negative integer to n (>32) bits binary. I fould 'Integer to Bit Converter' block having limit of number of bits up to 32, and functions 'de2bi' or 'dec2bin' only applicable for non-negtive integer. What can I do? Many thanks!!
  5 个评论
Qinghua
Qinghua 2011-12-20
I have to simulate the output from FPGA which has 43 signed bits and 35 signed bits registers.
Is it possible to program such convertion in Matlab?
Qinghua
Qinghua 2011-12-20
Thanks for advising. I tried:
>> A=de2bi(typecast(int64(-2^41),'uint64'),64,'left-msb');
>> B=A;
>> B(2:22)=[];
By this I can extract the signed 43 bits. But a new problem came when I tried with a smaller negetive integer:
>> de2bi(typecast(int64(-2),'uint64'),64,'left-msb');
It looks the N should be less than -2^16. For practical reason, I need to convert all input data to a same format (INT64). How can I do?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2011-12-20
The Fixed Point Toolbox is probably what you want.
  5 个评论
Fangjun Jiang
Fangjun Jiang 2011-12-20
The OP had another question indicating that. But I guess that MATLAB has a Fixed-Point Toolbox too.
Qinghua
Qinghua 2011-12-21
No matter Simulink or Matlab. I can't figure it out by neither of them: Is it possible to convert the nagtive integer e.g. -2199023255552 (-2^41), or -2 to 43 signed bits (or even 64 bits)?
Which functions can I use?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 String 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by