TWO's COMPLEMENT
Codes a number in binary form using two's complement representation
Contents
Function of MOBY-DIC TOOLBOX.
Description
Given an integer number, the function returns a string of characters ('0' and '1') coding the number in binary form. If the input number is negative, a two's complement representation is used.
Syntax
nbin = twoscomplement(ndec)
ndec is the integer number, nbin the same number in binary form
nbin = twoscomplement(ndec,nbit)
As above, but the number of bits used for coding is specified
Acknowledgements
Contributors:
- Alberto Oliveri (alberto.oliveri@unige.it)
Copyright is with:
- Copyright (C) 2012 University of Genoa, Italy.