Borrar filtros
Borrar filtros

convert negative integer to n (>32) bits?

1 visualización (últimos 30 días)
Qinghua
Qinghua el 20 de Dic. de 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 comentarios
Qinghua
Qinghua el 20 de Dic. de 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 el 20 de Dic. de 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?

Iniciar sesión para comentar.

Respuestas (1)

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

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by