Raymond Toy rtoy@common-lisp.net writes:
o Add support for hypot. This is used to test Lisp's ABS function on complex values.
Cool. I have ucblib-style input files for trunc()/FTRUNCATE in single and double precision. Do you think they should go into ucb/ucblib/, or should we treat that as pristine and place additions somewhere else?
Having trunc(), we are most of the way towards getting input files for rint(), which is basically ceil() in rounding mode p, floor() in rounding mode m, trunc() in rounding mode z; it's only complicated in rounding mode n.
There does remain a point for discussion, though: what Lisp function, if any, corresponds to rint()? The natural choice would be FROUND, but a case could be made for FROUND to be round-to-nearest always much as FTRUNCATE is round-to-zero always.
Perhaps this allows me to bring up a couple of ideas for things which should live in the IEEE754 package? Ideas: * specialised condition types: IEEE754:DIVISION-BY-ZERO and friends. The standard document says that it would be nice for programs to be able to find the faulting instruction and the operands from the handler; it would be nice to attempt to support this, at least for the IEEE-specified operations (+, -, *, /, sqrt and round-to-integer);
* functions to get at the individual bits in the fields: IEEE:DOUBLE-FLOAT-EXPONENT and friends. (I'm aware that the exponent field is biased; that makes design interesting)
* (maybe) implementations of functions which don't have any corresponding analogue in CL: IEEE754:LOG10? IEEE754:HYPOT? Maybe inspiration could be drawn from the C99 and C0X standards in this regard.
Anything else?
Cheers,
Christophe
"Christophe" == Christophe Rhodes csr21@cam.ac.uk writes:
Christophe> Raymond Toy rtoy@common-lisp.net writes: >> o Add support for hypot. This is used to test Lisp's ABS function on >> complex values.
Christophe> Cool. I have ucblib-style input files for trunc()/FTRUNCATE in single Christophe> and double precision. Do you think they should go into ucb/ucblib/, Christophe> or should we treat that as pristine and place additions somewhere Christophe> else?
My preference is to keep ucblib pristine. But if you don't that's ok.
Christophe> Perhaps this allows me to bring up a couple of ideas for things which Christophe> should live in the IEEE754 package? Ideas: Christophe> * specialised condition types: IEEE754:DIVISION-BY-ZERO and Christophe> friends. The standard document says that it would be nice for Christophe> programs to be able to find the faulting instruction and the Christophe> operands from the handler; it would be nice to attempt to support Christophe> this, at least for the IEEE-specified operations (+, -, *, /, sqrt Christophe> and round-to-integer);
This is a good idea. CMUCL/sparc already supports this, I think, but doesn't give the address of the faulting instruction, although it could.
It's a problem with x86 since the exceptions happen at the NEXT FP instruction, so the operands could have been destroyed before then. I think I tried to implement this for x86 long ago, but it didn't seem to work very well for some reason that I can't recall.
Christophe> * functions to get at the individual bits in the fields: Christophe> IEEE:DOUBLE-FLOAT-EXPONENT and friends. (I'm aware that the Christophe> exponent field is biased; that makes design interesting)
Provide both, perhaps? I note that cmucl's idea of the bias value is off by one from the bias value I see in most documents about IEEE754.
Christophe> * (maybe) implementations of functions which don't have any Christophe> corresponding analogue in CL: IEEE754:LOG10? IEEE754:HYPOT? Christophe> Maybe inspiration could be drawn from the C99 and C0X standards in Christophe> this regard.
Yes. From a peek at glibc's log10, it looks reasonably straight-forward. I think hypot could be done using complex-sqrt that's already in cmucl/sbcl. At least the hypot tests all pass, and we use complex-sqrt for abs of a complex number.
Should we provide for nextafter and copysign? Well, copysign is the same as Lisp's float-sign, with the args in the opposite order. There's also scalb (basically scale-float) and log2. We should provide those as well, I guess.
Ray
ieeefp-tests-devel@common-lisp.net