Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Power is danger. -- The Centurion, "Balance of Terror", stardate 1709.2


devel / comp.arch / Re: 0.0 / 0.0 = -NAN ?

SubjectAuthor
* Re: 0.0 / 0.0 = -NAN ?MitchAlsup
+- Re: 0.0 / 0.0 = -NAN ?Anton Ertl
+* Re: 0.0 / 0.0 = -NAN ?Terje Mathisen
|`* Re: 0.0 / 0.0 = -NAN ?Anton Ertl
| +* Re: 0.0 / 0.0 = -NAN ?Thomas Koenig
| |`* Re: 0.0 / 0.0 = -NAN ?Anton Ertl
| | `- Re: 0.0 / 0.0 = -NAN ?MitchAlsup
| `- Re: 0.0 / 0.0 = -NAN ?Niklas Holsti
+- Re: 0.0 / 0.0 = -NAN ?Michael S
`- Re: 0.0 / 0.0 = -NAN ?MitchAlsup

1
Re: 0.0 / 0.0 = -NAN ?

<8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24969&group=comp.arch#24969

 copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:aa49:0:b0:69f:cd34:7b25 with SMTP id t70-20020a37aa49000000b0069fcd347b25mr1015526qke.744.1651341269492;
Sat, 30 Apr 2022 10:54:29 -0700 (PDT)
X-Received: by 2002:a05:6830:1645:b0:606:fe3:fa21 with SMTP id
h5-20020a056830164500b006060fe3fa21mr260027otr.268.1651341269217; Sat, 30 Apr
2022 10:54:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sat, 30 Apr 2022 10:54:29 -0700 (PDT)
In-Reply-To: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:6ca0:b40:5195:80b5;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:6ca0:b40:5195:80b5
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com>
Subject: Re: 0.0 / 0.0 = -NAN ?
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Sat, 30 Apr 2022 17:54:29 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 32
 by: MitchAlsup - Sat, 30 Apr 2022 17:54 UTC

On Saturday, April 30, 2022 at 10:31:17 AM UTC-5, Skybuck Flying wrote:
> When exception masks are all enabled to stop the processor from throwing floating point exceptions the following calculation produces a somewhat strange result:
>
> 0.0 / 0.0 = -nan
<
IEEE 754 states:: division by zero creates properly signed NaNs.
+0.0/+0.0 = +NaN
-0.0/+0.0 = -NaN
+0.0/-0.0 = -NaN
-0.0/-0.0 = + NaN
>
> (At least in Delphi).
>
> For now I will assume this is the case in C/C++ as well and with that I mean on x86/x64 which should and seems to be following IEEE 754 floating-point format.
>
> I am a little bit surprised by this and I want/need to know more. Where is this defined that 0.0 / 0.0 should be -NAN ?!?
>
> Problem is with the code, example:
>
> T := 0;
> D := 0.0 / 0.0;
> P := T * D;
>
> This screws up P. instead of P being zero, P is now also -NAN ?!?
>
> I find this very strange but ok.
<
One of those 0.0s got a negative sign. But How ? Must be a Delphi thing.
>
> I guess a simple solution could be to set D to 0 explicitly for this case, is there perhaps another solution ? Maybe some kind of mask or rounding mode so that additional branch is not necessary ???
>
> Bye for now,
> Skybuck.

Re: 0.0 / 0.0 = -NAN ?

<2022May2.090846@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24979&group=comp.arch#24979

 copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: 0.0 / 0.0 = -NAN ?
Date: Mon, 02 May 2022 07:08:46 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 9
Message-ID: <2022May2.090846@mips.complang.tuwien.ac.at>
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com> <8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com> <22138cad-8d61-4d56-999a-22781c2657d5n@googlegroups.com> <be8d96ac-8de7-4d48-a764-79e2e5d1f693n@googlegroups.com>
Injection-Info: reader02.eternal-september.org; posting-host="67bf3c9f3c5f566b32e4161ec27af61c";
logging-data="24857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OU1iSbKZGEkCZ47xcaVek"
Cancel-Lock: sha1:OKFp2W57TqzqjgIZldAibCnImUo=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 2 May 2022 07:08 UTC

Skybuck Flying <skybuckflying@gmail.com> writes:
>if (NaN < A) is not the same as: (A >= NaN)

Actually, both comparisons produce false.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: 0.0 / 0.0 = -NAN ?

<t4o4v5$1bfp$1@gioia.aioe.org>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24980&group=comp.arch#24980

 copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!EhtdJS5E9ITDZpJm3Uerlg.user.46.165.242.91.POSTED!not-for-mail
From: terje.ma...@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: 0.0 / 0.0 = -NAN ?
Date: Mon, 2 May 2022 10:32:36 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t4o4v5$1bfp$1@gioia.aioe.org>
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com>
<8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com>
<22138cad-8d61-4d56-999a-22781c2657d5n@googlegroups.com>
<be8d96ac-8de7-4d48-a764-79e2e5d1f693n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="44537"; posting-host="EhtdJS5E9ITDZpJm3Uerlg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
Firefox/68.0 SeaMonkey/2.53.11.1
X-Notice: Filtered by postfilter v. 0.9.2
 by: Terje Mathisen - Mon, 2 May 2022 08:32 UTC

Skybuck Flying wrote:
> There is one "exception" to this NaN infects everything rule:
>
> if (A <> NaN) should return true ! ;)
>
> Haven't checked yet what Delphi does.
>
> Basically this would be an inversion of
>
> if not (A = NaN) I think...
>
> Also
>
> if (NaN < A) is not the same as: (A >= NaN)
>
> That last one... yikes... hehe bit tricky.

Not at all:

By definition, comparing anything to NaN should return false. This is
actually a way to determine if a number _is_ a NaN!

It is better to have a supported isnan(x) test function, but you can
write your own like this:

bool isnan(double x)
{ return !((x < 0.0) | (x >= 0.0)); // Both tests should be false!
}

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: 0.0 / 0.0 = -NAN ?

<2022May2.124751@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24981&group=comp.arch#24981

 copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: 0.0 / 0.0 = -NAN ?
Date: Mon, 02 May 2022 10:47:51 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 27
Message-ID: <2022May2.124751@mips.complang.tuwien.ac.at>
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com> <8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com> <22138cad-8d61-4d56-999a-22781c2657d5n@googlegroups.com> <be8d96ac-8de7-4d48-a764-79e2e5d1f693n@googlegroups.com> <t4o4v5$1bfp$1@gioia.aioe.org>
Injection-Info: reader02.eternal-september.org; posting-host="67bf3c9f3c5f566b32e4161ec27af61c";
logging-data="31719"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Lk3KaNRwUR4QVr693971V"
Cancel-Lock: sha1:iVDQCGEg1ai1BOH8hd3z/Sj1stA=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 2 May 2022 10:47 UTC

Terje Mathisen <terje.mathisen@tmsw.no> writes:
>By definition, comparing anything to NaN should return false.

You assume method to this madness. However, x <> NaN is specified to
produce true (in contrast to the other 5 conventional comparison
operators).

>It is better to have a supported isnan(x) test function, but you can
>write your own like this:
>
>bool isnan(double x)
>{
> return !((x < 0.0) | (x >= 0.0)); // Both tests should be false!
>}

Seems overly complicated

int isnan(double x) { return x!=x; }

Even without the extra madness of !=, you could write:

int isnan(double x) { return !(x=x); }

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: 0.0 / 0.0 = -NAN ?

<t4ov1u$2dr$1@newsreader4.netcologne.de>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24982&group=comp.arch#24982

 copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-f207-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: 0.0 / 0.0 = -NAN ?
Date: Mon, 2 May 2022 15:57:50 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <t4ov1u$2dr$1@newsreader4.netcologne.de>
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com>
<8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com>
<22138cad-8d61-4d56-999a-22781c2657d5n@googlegroups.com>
<be8d96ac-8de7-4d48-a764-79e2e5d1f693n@googlegroups.com>
<t4o4v5$1bfp$1@gioia.aioe.org> <2022May2.124751@mips.complang.tuwien.ac.at>
Injection-Date: Mon, 2 May 2022 15:57:50 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-f207-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:f207:0:7285:c2ff:fe6c:992d";
logging-data="2491"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Mon, 2 May 2022 15:57 UTC

Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
> Terje Mathisen <terje.mathisen@tmsw.no> writes:

>>It is better to have a supported isnan(x) test function, but you can
>>write your own like this:
>>
>>bool isnan(double x)
>>{
>> return !((x < 0.0) | (x >= 0.0)); // Both tests should be false!
>>}
>
> Seems overly complicated
>
> int isnan(double x) { return x!=x; }

Both are somewhat dangerous, as people may take the code one day
and run it through a compiler which removes these tests, for one
reason or another, specifying an option like -ffinite-math-only
being one of them.

Re: 0.0 / 0.0 = -NAN ?

<jdadeiFrkmvU1@mid.individual.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24983&group=comp.arch#24983

 copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.arch
Subject: Re: 0.0 / 0.0 = -NAN ?
Date: Mon, 2 May 2022 18:59:13 +0300
Organization: Tidorum Ltd
Lines: 29
Message-ID: <jdadeiFrkmvU1@mid.individual.net>
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com>
<8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com>
<22138cad-8d61-4d56-999a-22781c2657d5n@googlegroups.com>
<be8d96ac-8de7-4d48-a764-79e2e5d1f693n@googlegroups.com>
<t4o4v5$1bfp$1@gioia.aioe.org> <2022May2.124751@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 0gREdnsB96v8FD+z5SVdCQYJA2XK8PlmisF264UF0e3Mvcettr
Cancel-Lock: sha1:PDhDH6RnwSMq4EiPJveqFVp5VmQ=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:91.0)
Gecko/20100101 Thunderbird/91.6.2
Content-Language: en-US
In-Reply-To: <2022May2.124751@mips.complang.tuwien.ac.at>
 by: Niklas Holsti - Mon, 2 May 2022 15:59 UTC

On 2022-05-02 13:47, Anton Ertl wrote:
> Terje Mathisen <terje.mathisen@tmsw.no> writes:
>> By definition, comparing anything to NaN should return false.
>
> You assume method to this madness. However, x <> NaN is specified to
> produce true (in contrast to the other 5 conventional comparison
> operators).
>
>> It is better to have a supported isnan(x) test function, but you can
>> write your own like this:
>>
>> bool isnan(double x)
>> {
>> return !((x < 0.0) | (x >= 0.0)); // Both tests should be false!
>> }
>
> Seems overly complicated
>
> int isnan(double x) { return x!=x; }
>
> Even without the extra madness of !=, you could write:
>
> int isnan(double x) { return !(x=x); }

Rather, and as you no doubt meant, with the silly C double-equal:

int isnan(double x) { return !(x==x); }

Re: 0.0 / 0.0 = -NAN ?

<2022May2.185150@mips.complang.tuwien.ac.at>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24984&group=comp.arch#24984

 copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: 0.0 / 0.0 = -NAN ?
Date: Mon, 02 May 2022 16:51:50 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 36
Distribution: world
Message-ID: <2022May2.185150@mips.complang.tuwien.ac.at>
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com> <8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com> <22138cad-8d61-4d56-999a-22781c2657d5n@googlegroups.com> <be8d96ac-8de7-4d48-a764-79e2e5d1f693n@googlegroups.com> <t4o4v5$1bfp$1@gioia.aioe.org> <2022May2.124751@mips.complang.tuwien.ac.at> <t4ov1u$2dr$1@newsreader4.netcologne.de>
Injection-Info: reader02.eternal-september.org; posting-host="67bf3c9f3c5f566b32e4161ec27af61c";
logging-data="16127"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ROi0k5dXr2dlWCPpAellk"
Cancel-Lock: sha1:RwOAG5XdzZx02M86TmmLjjd+bjI=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Mon, 2 May 2022 16:51 UTC

Thomas Koenig <tkoenig@netcologne.de> writes:
>Anton Ertl <anton@mips.complang.tuwien.ac.at> schrieb:
>> Terje Mathisen <terje.mathisen@tmsw.no> writes:
>
>>>It is better to have a supported isnan(x) test function, but you can
>>>write your own like this:
>>>
>>>bool isnan(double x)
>>>{
>>> return !((x < 0.0) | (x >= 0.0)); // Both tests should be false!
>>>}
>>
>> Seems overly complicated
>>
>> int isnan(double x) { return x!=x; }
>
>Both are somewhat dangerous, as people may take the code one day
>and run it through a compiler which removes these tests, for one
>reason or another, specifying an option like -ffinite-math-only
>being one of them.

If they specify to the compiler that they don't use NaNs, always
returning 0 for isnan() is correct. Where's the danger?

Note that the gcc manual says about this option:

This option is not turned on by any -O option since it can result in
incorrect output for programs that depend on an exact implementation
of IEEE or ISO rules/specifications for math functions.

If a compiler performs this transformation on its own, it is broken.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: 0.0 / 0.0 = -NAN ?

<5c1c2d6e-0d12-496a-8523-b34d8932da5en@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24986&group=comp.arch#24986

 copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:622a:1111:b0:2f3:a419:4e05 with SMTP id e17-20020a05622a111100b002f3a4194e05mr6465827qty.657.1651524287841;
Mon, 02 May 2022 13:44:47 -0700 (PDT)
X-Received: by 2002:a05:6808:c2:b0:325:eb71:7266 with SMTP id
t2-20020a05680800c200b00325eb717266mr461905oic.269.1651524287593; Mon, 02 May
2022 13:44:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 2 May 2022 13:44:47 -0700 (PDT)
In-Reply-To: <8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:a5c1:c261:c4e6:5059;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:a5c1:c261:c4e6:5059
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com> <8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5c1c2d6e-0d12-496a-8523-b34d8932da5en@googlegroups.com>
Subject: Re: 0.0 / 0.0 = -NAN ?
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 02 May 2022 20:44:47 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 39
 by: Michael S - Mon, 2 May 2022 20:44 UTC

On Saturday, April 30, 2022 at 8:54:30 PM UTC+3, MitchAlsup wrote:
> On Saturday, April 30, 2022 at 10:31:17 AM UTC-5, Skybuck Flying wrote:
> > When exception masks are all enabled to stop the processor from throwing floating point exceptions the following calculation produces a somewhat strange result:
> >
> > 0.0 / 0.0 = -nan
> <
> IEEE 754 states:: division by zero creates properly signed NaNs.
> +0.0/+0.0 = +NaN
> -0.0/+0.0 = -NaN
> +0.0/-0.0 = -NaN
> -0.0/-0.0 = + NaN

Are you sure?
According to my reading of the standard, result of 0/0 has to be NaN, but there are no requirements for sign of the NaN.
From the standard: "When either an input or result is NaN, this standard does not interpret the sign of a NaN."

> >
> > (At least in Delphi).
> >
> > For now I will assume this is the case in C/C++ as well and with that I mean on x86/x64 which should and seems to be following IEEE 754 floating-point format.
> >
> > I am a little bit surprised by this and I want/need to know more. Where is this defined that 0.0 / 0.0 should be -NAN ?!?
> >
> > Problem is with the code, example:
> >
> > T := 0;
> > D := 0.0 / 0.0;
> > P := T * D;
> >
> > This screws up P. instead of P being zero, P is now also -NAN ?!?
> >
> > I find this very strange but ok.
> <
> One of those 0.0s got a negative sign. But How ? Must be a Delphi thing.
> >
> > I guess a simple solution could be to set D to 0 explicitly for this case, is there perhaps another solution ? Maybe some kind of mask or rounding mode so that additional branch is not necessary ???
> >
> > Bye for now,
> > Skybuck.

Re: 0.0 / 0.0 = -NAN ?

<c299c4f9-bc92-48e6-bb6b-07d58e8676cdn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24987&group=comp.arch#24987

 copy link   Newsgroups: comp.arch
X-Received: by 2002:ad4:5cae:0:b0:45a:90ea:43e with SMTP id q14-20020ad45cae000000b0045a90ea043emr3827674qvh.46.1651524856963;
Mon, 02 May 2022 13:54:16 -0700 (PDT)
X-Received: by 2002:a9d:75d0:0:b0:606:19e2:47e with SMTP id
c16-20020a9d75d0000000b0060619e2047emr2456526otl.298.1651524856728; Mon, 02
May 2022 13:54:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 2 May 2022 13:54:16 -0700 (PDT)
In-Reply-To: <be8d96ac-8de7-4d48-a764-79e2e5d1f693n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:b8e9:1ed6:4f6c:62c1;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:b8e9:1ed6:4f6c:62c1
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com>
<8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com> <22138cad-8d61-4d56-999a-22781c2657d5n@googlegroups.com>
<be8d96ac-8de7-4d48-a764-79e2e5d1f693n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c299c4f9-bc92-48e6-bb6b-07d58e8676cdn@googlegroups.com>
Subject: Re: 0.0 / 0.0 = -NAN ?
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Mon, 02 May 2022 20:54:16 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 27
 by: MitchAlsup - Mon, 2 May 2022 20:54 UTC

On Sunday, May 1, 2022 at 11:52:08 PM UTC-5, Skybuck Flying wrote:
> There is one "exception" to this NaN infects everything rule:
>
> if (A <> NaN) should return true ! ;)
<
A == A -> FALSE means A is a NaN.
>
> Haven't checked yet what Delphi does.
>
> Basically this would be an inversion of
>
> if not (A = NaN) I think...
>
> Also
>
> if (NaN < A) is not the same as: (A >= NaN)
<
Given that NaNs exist,
NaN < A can never be considered to be !(NaN >= A)
<
What happens is that these kinds of comparisons change which
clause the NaNs go into (should be the else clause but inversion
changes them to the then clause.)
>
> That last one... yikes... hehe bit tricky.
>
> Bye,
> Skybuck

Re: 0.0 / 0.0 = -NAN ?

<e66d9fc8-8166-4211-9ea5-d0b15ab6b753n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=24988&group=comp.arch#24988

 copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:622a:15d1:b0:2f3:4dad:9f4 with SMTP id d17-20020a05622a15d100b002f34dad09f4mr12095125qty.287.1651525063422;
Mon, 02 May 2022 13:57:43 -0700 (PDT)
X-Received: by 2002:a05:6808:1141:b0:325:cd92:ef8d with SMTP id
u1-20020a056808114100b00325cd92ef8dmr486461oiu.228.1651525063196; Mon, 02 May
2022 13:57:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 2 May 2022 13:57:43 -0700 (PDT)
In-Reply-To: <2022May2.185150@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:b8e9:1ed6:4f6c:62c1;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:b8e9:1ed6:4f6c:62c1
References: <83274dd7-3dfa-4dc5-8ff2-aed29f253b1an@googlegroups.com>
<8512fdb0-1f32-436b-b803-340908c302fen@googlegroups.com> <22138cad-8d61-4d56-999a-22781c2657d5n@googlegroups.com>
<be8d96ac-8de7-4d48-a764-79e2e5d1f693n@googlegroups.com> <t4o4v5$1bfp$1@gioia.aioe.org>
<2022May2.124751@mips.complang.tuwien.ac.at> <t4ov1u$2dr$1@newsreader4.netcologne.de>
<2022May2.185150@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e66d9fc8-8166-4211-9ea5-d0b15ab6b753n@googlegroups.com>
Subject: Re: 0.0 / 0.0 = -NAN ?
From: MitchAl...@aol.com (MitchAlsup)
Injection-Date: Mon, 02 May 2022 20:57:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 40
 by: MitchAlsup - Mon, 2 May 2022 20:57 UTC

On Monday, May 2, 2022 at 12:00:57 PM UTC-5, Anton Ertl wrote:
> Thomas Koenig <tko...@netcologne.de> writes:
> >Anton Ertl <an...@mips.complang.tuwien.ac.at> schrieb:
> >> Terje Mathisen <terje.m...@tmsw.no> writes:
> >
> >>>It is better to have a supported isnan(x) test function, but you can
> >>>write your own like this:
> >>>
> >>>bool isnan(double x)
> >>>{
> >>> return !((x < 0.0) | (x >= 0.0)); // Both tests should be false!
> >>>}
> >>
> >> Seems overly complicated
> >>
> >> int isnan(double x) { return x!=x; }
> >
> >Both are somewhat dangerous, as people may take the code one day
> >and run it through a compiler which removes these tests, for one
> >reason or another, specifying an option like -ffinite-math-only
> >being one of them.
<
> If they specify to the compiler that they don't use NaNs, always
> returning 0 for isnan() is correct. Where's the danger?
<
Some calculation can produce a NaN, and then overly agressive
optimization creates the opportunity for the program to simply
fail unexpectedly. No Compiler should ever remove a comparison
designed to ferret NaNs from values.
>
> Note that the gcc manual says about this option:
>
> This option is not turned on by any -O option since it can result in
> incorrect output for programs that depend on an exact implementation
> of IEEE or ISO rules/specifications for math functions.
>
> If a compiler performs this transformation on its own, it is broken.
> - anton
> --
> 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor