Rank: 1406 based on 47 downloads (last 30 days) and 1 file submitted
photo

Tal Levinger

E-mail
Company/University
BG University

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Tal
Updated   File Tags Downloads
(last 30 days)
Comments Rating
19 Jul 2004 Two's Complement for MATLAB Calculating two's complement for a decimal number. Author: Tal Levinger twos complement, calculate, matlab, signed integer 47 5
  • 4.0
4.0 | 5 ratings
Comments and Ratings on Tal's Files View all
Updated File Comment by Comments Rating
30 Jan 2012 Two's Complement for MATLAB Calculating two's complement for a decimal number. Author: Tal Levinger duanra

 if N is the number of bit
and b an array of integer to convert in signed this operation could be faster

       if( b(n) > (2^(N-1)-1))
            b(n)=b(n)-2^N;
        else
            b(n)=b(n);
        end;

13 Nov 2010 Two's Complement for MATLAB Calculating two's complement for a decimal number. Author: Tal Levinger Naseri, Hassan

function value = dec2tc(dec, N)
value = dec2bin(mod((dec),2^N),N);
end

function value = tc2dec(bin,N)
val = bin2dec(bin);
y = sign(2^(N-1)-val)*(2^(N-1)-abs(2^(N-1)-val));
if ((y == 0) && (val ~= 0))
  value = -val;
else
    value = y;
end
end

07 Sep 2007 Two's Complement for MATLAB Calculating two's complement for a decimal number. Author: Tal Levinger Baur, Rafael

there is a easier way to calculate the two's complement:
twos_comp = dec2bin(mod((value),2^bits),bits);

look at a those two's complement circles then you will see why it works.

07 May 2007 Two's Complement for MATLAB Calculating two's complement for a decimal number. Author: Tal Levinger Webb, Chad

Handy for 16 bit numbers, but not anything else. It even takes an input for what appears to be the number of bits (i.e. other than 16), but never utilizes it. Good start on a function that could be far more useful.

22 Apr 2007 Two's Complement for MATLAB Calculating two's complement for a decimal number. Author: Tal Levinger donegor, igi
Top Tags Applied by Tal
calculate, matlab, signed integer, twos complement
Files Tagged by Tal
Updated   File Tags Downloads
(last 30 days)
Comments Rating
19 Jul 2004 Two's Complement for MATLAB Calculating two's complement for a decimal number. Author: Tal Levinger twos complement, calculate, matlab, signed integer 47 5
  • 4.0
4.0 | 5 ratings

Contact us at files@mathworks.com