Re: Division durch Null



Roland Damm <roland-damm@xxxxxxxx> wrote:
Moin,

Thomas Richter schrub:

Bei IEEE-Fließkommazahlen für eine FPU wie vom OP angefragt?
Eher nicht. Da gibt es INF, um diesen Zustand auszudrücken...

IMO gibt es nicht nur INF, sondern sogar +/- INF und NAN.
Division durch Null ist dann eher ein Kandidat für NAN, weil ja
das Vorzeichen von INF nicht bekannt ist.

CU Rollo

Ach ja? Auch wenn es fachfremd ist, aus dem AMD64 Architecture
Programmer's Manual Volume 5: 64-Bit Media and x87- Floating-Point
Instructions, Abschnitt über fdiv:

|If the zero-divide exception is not masked (ZM bit cleared to 0 in the
|x87 control word) and the operation causes a zero-divide exception (sets
|the ZE bit in the x87 status word to 1), the operation stores no result.
|If the zero-divide exception is masked (ZM bit set to 1), a zero-divide
|exception causes "infinity" to be stored.
|
|The sign of the operands, even if one of the operands is 0, determines
|the sign of the result.

Noch Fragen?

Also: +finite/+0 = +infinity
+finite/-0 = -infinity
-finite/+0 = -infinity
-finite/-0 = +infinity

Und "finite" schließt 0 mit ein. Das IEEE-754-Floating-Point-Format
funktioniert halt mit Sign Bit, deswegen gibt es einen Unterschied
zwischen +0 und -0, auch wenn er nur ein Bit ist.

Was ich nicht weiß, ist, was passiert, wenn einer der Operanden
unendlich ist. Mal sehen, was nach der Analysis geschehen müsste:

(+-)infinity/+finite = (+-)infinity
(+-)infinity/-finite = (-+)infinity
+finite/(+-)infinity = (+-)0
-finite/(+-)infinity = (-+)0

Und wenn einer der Operanden NaN ist, ist das Ergebnis natürlich auch
NaN. Vorausgesetzt, die Invalid Exception ist gemaskt oder die NaNs sind
QNaNs.

Tschö,
Markus
--
GUI - ein Hintergrundbild und zwölf XTerms

vim -c "exec \"norm iwHFG#NABGURE#IVZ#UNPXRE\"|%s/#/ /g|norm g??g~~"
.



Relevant Pages

  • Re: float("nan") in set or as key
    ... >>> nan ... exception here, ... INF - INF NaN ... Given that the language handles integer overflow by going to ...
    (comp.lang.python)
  • Re: cexp implementation questions
    ... while one might expect NaN. ... "inf inf" is as correct as any other result. ... a zero imaginary part. ...   "The rule for determining the result of an operation that has infinity ...
    (comp.lang.c)
  • Re: xpc lockup
    ... INF or NAN values. ... sending it to an xPC Target Scope using Graphical Redraw. ... try each of the I/O devices in turn. ...
    (comp.soft-sys.matlab)
  • Re: getline - sort of
    ... Also errno should be checked so that overflow can easily be detected. ... Hmm, a description under half the length suggests to me that it is a LOT simpler to use strtoul, strtoull, strtol or strtoll depending on valid range. ... If the user passes NAN or INF, it is an open question what the correct behaviour should be. ...
    (comp.lang.c)
  • Re: getline - sort of
    ... Also errno should be checked so that overflow can easily be detected. ... Hmm, a description under half the length suggests to me that it is a LOT simpler to use strtoul, strtoull, strtol or strtoll depending on valid range. ... If the user passes NAN or INF, it is an open question what the correct behaviour should be. ...
    (comp.lang.c)