Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: decimal fraction to binary conversion Date: Fri, 2 Dec 2011 14:51:08 +0000 (UTC) Organization: Georgia Institute of Technology Lines: 14 Message-ID: <jbaoks$guf$1@newscl01ah.mathworks.com> References: <jbab7h$47b$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: www-03-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1322837468 17359 172.30.248.48 (2 Dec 2011 14:51:08 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 2 Dec 2011 14:51:08 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1760883 Xref: news.mathworks.com comp.soft-sys.matlab:751219 "hend " <eng.hr2009@yahoo.com> wrote in message <jbab7h$47b$1@newscl01ah.mathworks.com>... > Hello everybody; > > i'm in need to a program code which can convert negative fractions into binary form ( any form ) .. > dec2bin command is not helpful in this case ! There are several problems here. You will have to utilize a scheme such as Two's complement in order to represent both positive and negative numbers in binary form. You will need to add a sign bit before the binary number representing the number. So if you want to represent +5, 5 would typically be 101, but add a sign bit and it becomes 0101. Now to represent a negative number, your sign bit will be 1 and the following numbers will be the two's complement of 5 and you end up with 1011. You can read more here: http://en.wikipedia.org/wiki/Two's_complement Also, dec2bin doesn't handle fractions like you think, it returns the binary representation of only the integer portion of your input.