Be the first to rate this file! 56 downloads (last 30 days) File Size: 1.55 KB File ID: #14900

Two's Complement

by Chad Webb

 

07 May 2007 (Updated 07 May 2007)

No BSD License  

Compute the two's complement value of an unsigned integer

Download Now | Watch this File

File Information
Description

This is a very simple utility that computes the two's complement value from an unsigned integer input. The number of bits of the input integer must also be specified

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Two's Complement for MATLAB, from decimal to two's complement

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
09 May 2007 Loren Shure

Would be nice if this were vectorized. That would mean not using the if statement but instead operating on the entries where msb was true, but not the others.

30 Oct 2008 Jeremy

um...the 2's complement of an unsigned value is just the dec2bin function...what's the point if it's unsigned?

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
twos complement Chad Webb 22 Oct 2008 09:12:01
compute Chad Webb 22 Oct 2008 09:12:01
utility Chad Webb 22 Oct 2008 09:12:01
integer Chad Webb 22 Oct 2008 09:12:01
unsigned Chad Webb 22 Oct 2008 09:12:01
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com