Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #16137

Re: zero up memory

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: zero up memory
Date 2012-01-24 17:43 -0500
Organization A noiseless patient Spider
Message-ID <4F1F33F9.4020904@verizon.net> (permalink)
References (3 earlier) <ln4nvmwcz1.fsf@nuthaus.mib.org> <20120123120939.71@kylheku.com> <e5ca3c84-58fa-4cee-aa8d-88dc3de2d899@j42g2000vbt.googlegroups.com> <0.643ec697f8276b5bf722.20120123232115GMT.871uqqhuok.fsf@bsb.me.uk> <40e1a29a-80ab-4b1a-bc54-119f148dd78a@8g2000vbv.googlegroups.com>

Show all headers | View raw


On 01/24/2012 12:35 PM, Malcolm McLean wrote:
> On Jan 23, 11:21 pm, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
>>
>> In systems where the mantissa is not normalised (i.e. there is no
>> implicit leading 1) then zero is specified quite naturally with a zero
>> mantissa.  A zero sign bit and exponent (even it biased) makes no
>> difference.  Systems like this are common: IEEE decimal floating point
>> and IBM's hexadecimal floating point come to mind.
>>
> So how does the processor do equality comparisons, efficiently?
> 
> If the mantissa is not normalized then there are many possible
> representations for each number, including zero.

The case that I'm most familiar with, IEEE 754 double precision,
sub-normal numbers have an exponent of 0, a sign bit, and 52 bits of
mantissa, and represent the values (-1)^sign * mantissa* 2^(-1022-52).
The smallest positive value that can be represented is 2^(-1074), the
largest is 2^(-1022) - 2^(-1074).

For normal numbers, 0<exponent && exponent < 0x7FF. The value
represented is (-1)^sign*(1.mantissa)*2^(exponent - 1023). The smallest
positive value represented by this mechanism occurs when mantissa is 0
and exponent is 1, which represents 2^(-1022). That is exactly 2^-1074
bigger than the biggest subnormal value.

The exponent value 0x7FF is reserved for infinities and NaNs.

There doesn't seem to be any overlap in the ranges of normal and
subnormal values, and within each category, all of the non-zero values
that can be represented have a unique representation. A value of exactly
0 must have it's mantissa and exponent both zero, but can have it's sign
bit either set or cleared. As a result, equality comparisons can be
replaced by memcmp(), except for the special handling required by IEEE
754 for +0, -0, infinities and NaNs.
Within this scheme, could you provide an example of the "many possible
representations for each number" that you're referring to?

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

zero up memory "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2012-01-23 10:51 -0500
  Re: zero up memory Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-23 16:30 +0000
  Re: zero up memory Johann Klammer <klammerj@NOSPAM.a1.net> - 2012-01-23 17:57 +0100
    Re: zero up memory Kenneth Brody <kenbrody@spamcop.net> - 2012-01-23 12:07 -0500
    Re: zero up memory Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-01-23 09:08 -0800
      Re: zero up memory Keith Thompson <kst-u@mib.org> - 2012-01-23 09:22 -0800
        Re: zero up memory Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-01-23 10:13 -0800
          Re: zero up memory Keith Thompson <kst-u@mib.org> - 2012-01-23 12:00 -0800
        Re: zero up memory Kaz Kylheku <kaz@kylheku.com> - 2012-01-23 20:14 +0000
          Re: zero up memory "Joel C. Salomon" <joelcsalomon@gmail.com> - 2012-01-23 16:46 -0500
          Re: zero up memory Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-01-23 14:05 -0800
            Re: zero up memory Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-23 23:21 +0000
              Re: zero up memory Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-01-24 09:35 -0800
                Re: zero up memory Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-24 20:56 +0000
                Re: zero up memory Keith Thompson <kst-u@mib.org> - 2012-01-24 14:07 -0800
                Re: zero up memory Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-25 17:38 +0000
                Re: zero up memory Johann Klammer <klammerj@NOSPAM.a1.net> - 2012-01-24 23:15 +0100
                Re: zero up memory Keith Thompson <kst-u@mib.org> - 2012-01-24 14:31 -0800
                Re: zero up memory Kleuske <kleuske@nowhere.net> - 2012-01-25 15:39 +0000
                Re: zero up memory Kleuske <kleuske@nowhere.net> - 2012-01-25 15:49 +0000
                Re: zero up memory Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-26 03:09 -0800
                Re: zero up memory Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-01-25 13:05 -0800
                Re: zero up memory Sjouke Burry <s@b> - 2012-01-25 23:25 +0000
                Re: zero up memory Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-26 03:11 -0800
                Re: zero up memory Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-01-26 11:48 -0800
                Re: zero up memory gordonb.p79fg@burditt.org (Gordon Burditt) - 2012-03-12 17:55 -0500
                Re: zero up memory James Kuyper <jameskuyper@verizon.net> - 2012-03-12 22:10 -0400
                Re: zero up memory Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-03-12 23:24 -0400
                Re: zero up memory James Kuyper <jameskuyper@verizon.net> - 2012-03-12 23:53 -0400
                Re: zero up memory gordonb.pu5nu@burditt.org (Gordon Burditt) - 2012-03-13 00:58 -0500
                Re: zero up memory James Kuyper <jameskuyper@verizon.net> - 2012-03-14 11:17 -0400
                Re: zero up memory Keith Thompson <kst-u@mib.org> - 2012-01-26 11:19 -0800
                Re: zero up memory Kleuske <kleuske@nowhere.net> - 2012-01-27 08:13 +0000
                Re: zero up memory Kleuske <kleuske@nowhere.net> - 2012-01-26 14:42 +0000
                Re: zero up memory Keith Thompson <kst-u@mib.org> - 2012-01-25 12:33 -0800
                Re: zero up memory Kleuske <kleuske@nowhere.net> - 2012-01-26 14:12 +0000
                Re: zero up memory James Kuyper <jameskuyper@verizon.net> - 2012-01-24 17:43 -0500
                Re: zero up memory Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-01-24 16:29 -0800
                Re: zero up memory James Kuyper <jameskuyper@verizon.net> - 2012-01-24 21:43 -0500
                Re: zero up memory Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-01-24 23:58 -0800
                Re: zero up memory Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-25 17:52 +0000
                Re: zero up memory Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-25 17:48 +0000
                Re: zero up memory Robert Wessel <robertwessel2@yahoo.com> - 2012-01-25 12:15 -0600
                Re: zero up memory blp@cs.stanford.edu (Ben Pfaff) - 2012-01-25 10:35 -0800
                Re: zero up memory Robert Wessel <robertwessel2@yahoo.com> - 2012-01-25 17:15 -0600
                Re: zero up memory Robert Wessel <robertwessel2@yahoo.com> - 2012-01-25 17:23 -0600
                Re: zero up memory "BartC" <bc@freeuk.com> - 2012-01-25 23:51 +0000
                Re: zero up memory Robert Wessel <robertwessel2@yahoo.com> - 2012-01-26 18:35 -0600
                Re: zero up memory James Kuyper <jameskuyper@verizon.net> - 2012-01-25 13:17 -0500
          Re: zero up memory Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-23 22:55 +0000
      Re: zero up memory jgk@panix.com (Joe keane) - 2012-01-24 20:45 +0000
        Re: zero up memory Keith Thompson <kst-u@mib.org> - 2012-01-24 14:13 -0800

csiph-web