[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: William D Clinger <cesura@xxxxxxxxxxx>*Subject*: Re: external representations*From*: Bradley Lucier <lucier@xxxxxxxxxxxxxxx>*Date*: Mon, 27 Jun 2005 15:56:56 -0500*Cc*: Bradley Lucier <lucier@xxxxxxxxxxxxxxx>, srfi-70@xxxxxxxxxxxxxxxxx*Delivered-to*: srfi-70@xxxxxxxxxxxxxxxxx*In-reply-to*: <y9loe9wjs9d.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>*References*: <y9loe9wjs9d.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

On Jun 23, 2005, at 11:25 PM, William D Clinger wrote:

Bradley Lucier wrote:Re: Your idea of representing common Scheme values as NaNs. I believe it is possible under IEEE 754 that the "hardware" could return a different NaN for each execution of (/ 0. 0.) in the code (for example). (Some proposals have suggested putting the address of the code and/or a rough time stamp in the mantissa.) I'm a bit concerned that a floating-point operation could return a value that would be interpreted by your scheme as #\C (for example).Interesting. Can you tell me of any hardware that actually does this?

we find

A NaN may have an associated code that indicates its origin. Thesecodes are listed in Table 2-3. The NaN code is the 8th through 15thmost significant bits of the fraction field.Table 2-3 NaN codes Decimal Hexadecimal Meaning 1 0x01 Invalid square root, such as SQRT-1 2 0x02 Invalid addition, such as (+ )+(- ) 4 0x04 Invalid division, such as 0/0 8 0x08 Invalid multiplication, such as 0× 9 0x09 Invalid remainder or modulo, such as x rem 0 17 0x11 Attempt to convert invalid ASCII string 21 0x15 Attempt to create a NaN with a zero code33 0x21 Invalid argument to trigonometric function (such ascos, sin, tan)34 0x22 Invalid argument to inverse trigonometric function(such as acos, asin, atan)36 0x24 Invalid argument to logarithmic function (such aslog, log10 )37 0x25 Invalid argument to exponential function (such asexp, expm1)38 0x26 Invalid argument to financial function (compound orannuity)40 0x28 Invalid argument to inverse hyperbolic function (suchas acosh, asinh)42 0x2A Invalid argument to gamma function (gamma or lgamma) Note The PowerPC processor always returns 0 for the NaN code.

and the following code gives [descartes:~] lucier% gcc -Wall -o testfp testfp.c -save-temps [descartes:~] lucier% ./testfp 7ff8000000000000 7ff8048000000000 7ff8044000000000 7ff8000000000000 [descartes:~] lucier% cat testfp.c #include <stdio.h> #include <math.h> int main() { union { long long int i; double d; } x, y, z, a; x.d = sqrt(-1.0); y.d = log (-1.0); z.d = acos(2.0); a.d = (1.0 / 0.0) - (1.0 / 0.0); printf("%llx %llx %llx %llx\n", x.i, y.i, z.i, a.i); return 0; }

Brad

**References**:**Re: external representations***From:*William D Clinger

- Prev by Date:
**precise-numbers** - Next by Date:
**Re: comparison operators and *typos** - Previous by thread:
**Re: external representations** - Next by thread:
**Re: comparison operators and *typos** - Index(es):