Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: zero up memory |
| Date | 2012-01-24 14:31 -0800 |
| Organization | None to speak of |
| Message-ID | <lnzkdc68c5.fsf@nuthaus.mib.org> (permalink) |
| References | (4 earlier) <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> <4f1f2d6e$0$18693$91cee783@newsreader03.highway.telekom.at> |
Johann Klammer <klammerj@NOSPAM.a1.net> writes:
> Malcolm McLean wrote:
>> 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.
>
> Usually one does an epsilon test.
> with epsilon rather small
>
> if(((a+epsilon)<b)&&((a-epsilon)>b))
> {
>
> }
That doesn't address the question, which is how the processor performs a
floating-point equality test, the one specified by C's "==" operator.
> The following will most likely evaluate to false on intel machines
> The compiler just does a (bitwise)equality test.
>
> a=+0.0;
> b=-0.0;
>
> if(a==b)
> {
>
> }
Only if the compiler is broken. "a==b" yields 1 if a and b are
*numerically* equal, 0 if they're not. If two bit patterns represent
the same value, bitwise comparison will not work.
Oh, and "b=-0.0" won't set b to a floating-point negative zero.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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