필터 지우기
필터 지우기

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