From: tlaronde@polynum.com
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] Arithmetic on Plan 9
Date: Thu, 26 Jul 2007 00:52:17 +0200 [thread overview]
Message-ID: <20070725225216.GA735@polynum.com> (raw)
In-Reply-To: <14ec7b180707250925r27e6b8f1vdc53a2dc4430432f@mail.gmail.com>
On Wed, Jul 25, 2007 at 10:25:28AM -0600, andrey mirtchovski wrote:
>[...]
> in my particular case the code I was porting defined NaN as a constant
> and threw an exception whenever it ran. one particular quirk that i
> observed was that an exception was thrown regardless of whether I
> defined a silent or a non-silent NaN... my "solution" was simply to
> turn off FPINVAL via setfcr(). if you're porting via ape, as i was
> doing, the best solution is to get the little bits of assembly that
> constitute the *fcr routines, compile them with 8a and link them
> against the
Perhaps a hint on this. In The Intel documentation (Intel64 and IA32
Architectures Software Developer's Manual, Volume 1, §4.8.3.4):
------quote
SNaNs are typically used to trap or invoke an exception handler.
They must be inserted by software; that is, the processor never
generates an SNaN as a result of a loating-point operation.
------endquote
As a result, on x87, the invalid operations all cause an exception, and
it is the responsability of software to create/insert NaNs, whether
sNaN or qNAN.
And furthermore (§4.8.3.6):
------quote
· If one of the source operands is an SNaN and the floating-point
invalid-operating exception is not masked (see Section 4.9.1.1,
"Invalid Operation Exception (#I)"), the a floating-point
invalid-operation exception is signaled and no result is stored in
the destination operand.
· If either or both of the source operands are NaNs and floating-point
invalid- operation exception is masked, the result is as shown in
Table 4-7. When an SNaN is converted to a QNaN, the conversion is
handled by setting the most- significant fraction bit of the SNaN
to 1. Also, when one of the source operands is an SNaN, the
floating-point invalid-operation exception flag it set. Note that
for some combinations of source operands, the result is different
for x87 FPU operations and for SSE/SSE2/SSE3 operations.
· When neither of the source operands is a NaN, but the operation
generates a floating-point invalid-operation exception (see Tables
8-10 and 11-1), the result is commonly an SNaN source operand
converted to a QNaN or the QNaN floating- point indefinite value.
------endquote
So masking the floating-point invalid-operation, even in case of QNaN,
if I understand correctly, was indeed required to shut up the exception.
Note: I have the documentation for Plan 9 in hardcopy (from Vita Nuova),
and I just found some information about IEEE support in the paper called:
"The Various Ports".
To summarize: for Motorola MC68020 and x86, there is IEEE754 hardware
support and there is full IEEE support.
For chips where there is a FPU but only a partial support, in hardware,
for IEEE754, there is emulation, but not a complete one: "we implement
non trapping-underflow as truncation to zero and do nothing about
denormalized numbers and not-a-numbers."
There is also notes about transcendantal functions (built-in or emulated
in library).
--
Thierry Laronde (Alceste) <tlaronde +AT+ polynum +dot+ com>
http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
prev parent reply other threads:[~2007-07-25 22:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-25 15:51 tlaronde
2007-07-25 15:57 ` [9fans] " tlaronde
2007-07-25 16:25 ` [9fans] " andrey mirtchovski
2007-07-25 18:22 ` tlaronde
2007-07-25 22:52 ` tlaronde [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070725225216.GA735@polynum.com \
--to=tlaronde@polynum.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).