Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: bert Newsgroups: comp.arch Subject: Re: IEEE-754-2008 2's complement question Date: Sun, 4 Mar 2012 12:05:06 -0800 (PST) Organization: http://groups.google.com Lines: 57 Message-ID: <9410230.2390.1330891506752.JavaMail.geo-discussion-forums@vbw15> References: <999f8083-6a41-4c59-b42f-883d8c8e9192@pz2g2000pbc.googlegroups.com> NNTP-Posting-Host: 86.163.114.140 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1330891507 22920 127.0.0.1 (4 Mar 2012 20:05:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 4 Mar 2012 20:05:07 +0000 (UTC) In-Reply-To: <999f8083-6a41-4c59-b42f-883d8c8e9192@pz2g2000pbc.googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=86.163.114.140; posting-account=n7oCtQoAAACNS6CgW2a2eDoP2d9IRGfY User-Agent: G2/1.0 Xref: csiph.com comp.arch:6223 On Sunday, March 4, 2012 1:12:57 PM UTC, Daku wrote: > Could some computer architecture guru please > clarify this a bit ? > Suppose I have a signed fraction as -0.25 > The IEEE-754-2008 representation(with > "hidden bit") of it is: > > Sign Exponent Mantissa > 1 01111110 1.0000000000000000000000 > > Now suppose I wish to add it to 100.0 > First of all, the 2's complement of the > mantissa has to be obtained. The > question is whether the "hidden bit" is > also inverted. > > If yes, the 2's complement for this > mantissa is > 0.11111111111111111111111 > 1 > Resulting in, after the above addition > in 1.000000000000000000000000 > > Is this reasoning correct ? Or is the > "hidden bit" not taken into account > in the 2's complement calculation ? No. Back around 1981 I wrote microcode to implement this floating-point representation on a bit-slice processor, so it goes (as far as I remember now): (a) the exponent of your 100.0 is way way bigger than the exponent of 0.25, so to align the exponents:- (b) logically shift the 0.25 fraction and its hidden bit 9 places to the right, and (notionally only) increment its exponent by 9. (c) the exponents now match, so according to the signs of the fractions and the specified operation (+ or -), add or subtract them, including the hidden bit of the larger fraction. When it's subtraction instead of addition, then of course the smaller fraction will be fully 2's complemented. (d) in this case we will just re-hide the hidden bit of the result fraction, but ... (e) in other subtraction cases we may have to shift the result fraction up 1 or more places, and in the case of addition we may have to shift the result fraction down 1 place, adjusting the exponent appropriately in either case. That's it, apart from correct result rounding (can be quite a pain) and underflow and overflow. --