Filter löschen
Filter löschen

convert negative integer to n (>32) bits?

1 Ansicht (letzte 30 Tage)
Qinghua
Qinghua am 20 Dez. 2011
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 Kommentare
Qinghua
Qinghua am 20 Dez. 2011
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 am 20 Dez. 2011
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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 20 Dez. 2011
The Fixed Point Toolbox is probably what you want.
  5 Kommentare
Fangjun Jiang
Fangjun Jiang am 20 Dez. 2011
The OP had another question indicating that. But I guess that MATLAB has a Fixed-Point Toolbox too.
Qinghua
Qinghua am 21 Dez. 2011
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?

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by