Raymond Toy: > Jan Rychter wrote: > > In the following snippet of code: > > > > #'(lambda (v1 v2) > > (values (- (the double-float (log v1)) > > (the double-float (log v2))) > > 0)) > > > > Is there a better way to tell CMUCL that I'm really sure that v1 and v2 > > are greater than 0.0d0 and are double-floats, so that the compiler > > doesn't have to worry about the result of the logs becoming a COMPLEX? > > > > I've tried things like: > > > > (declare (type (double-float 0.0d0) v1)) > > > > That declaration means the v1 can be +/- 0.0 to +infinity, and CMUCL > thinks log of -0.0 is a complex number.
Indeed! You are right. I have completely forgotten about negative zeroes. > You probably want > > (declare (type (double-float (0d0)) v1) > > This means v1 is strictly positive. If v1 can also be +0.0, you can say > > (declare (type (or (double-float (0d0) (member 0d0)) v1) Thank you, this is a very helpful answer. This indeed works perfectly fine. I am not worried about the +0.0 value, as this would cause a DIVISION-BY-ZERO anyway and cannot happen in my code. By the way, where does one find out about the (double-float (0d0)) syntax (with parentheses around 0d0)? Having reread the CMUCL manual chapters on compiler and optimization and having looked at the HyperSpec again, I cannot seem to find a description of this anywhere? --J.
