Effacer les filtres
Effacer les filtres

convert negative integer to n (>32) bits?

1 vue (au cours des 30 derniers jours)
Qinghua
Qinghua le 20 Déc 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 commentaires
Qinghua
Qinghua le 20 Déc 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 le 20 Déc 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?

Connectez-vous pour commenter.

Réponses (1)

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

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by