"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