[Openmcl-devel] Bug receiving floats or doubles in callbacks

Gary Byers gb at clozure.com
Thu Aug 4 23:48:57 PDT 2005



On Fri, 5 Aug 2005, Luis Oliveira wrote:

> Hello,
>
> Callbacks in OpenMCL seem to receive single- or double-float
> arguments incorrectly. Here's an example:
>
>  #include <stdio.h>
>
>  void expect_float(float (*f)(float))
>  {
>      printf("f(42.0f) => %f\n", f(42.0f));
>  }
>
>  void expect_double(double (*f)(double))
>  {
>      printf("f(42.0) => %f\n", f(42.0));
>  }
>
>
> Having compiled and loaded the above C code:
>
>  ? (defcallback return-float (:single-float n :single-float)
>      (format t "Lisp side got: ~A~%" n)
>      42.0)
>  RETURN-FLOAT
>
>  ? (external-call "_expect_float" :address return-float)
>  f(42.0f) => 42.000000
>  Lisp side got: 1.4814527E-39
>  NIL
>
>  ? (defcallback return-double (:double-float n :double-float)
>      (format t "Lisp side got: ~A~%" n)
>      42.0d0)
>  RETURN-DOUBLE
>
>  ? (external-call "_expect_double" :address return-double)
>  f(42.0) => 42.000000
>  Lisp side got: 2.2434418562267333D-308
>  NIL
>
>
> I hope this report helps.

It does.  (Although I can probably guess that you're using OpenMCL 0.14.3
on OSX, it's also really helpful to know that sort of thing.)

I was about to say that "this will be fixed in the next release" (someone
reported very similar symptoms a few weeks ago), but the SINGLE-FLOAT case
was still broken.

Optimistically, that next release should be available "soon".  I'm not
sure exactly how soon;  if anyone needs a fix for this sooner than "soon",
it might be easier to get that fix into the 0.14.3 tree than I'd first
thought that it was.


>
> -- 
> Luis Oliveira
> luismbo (@) gmail (.) com
> Equipa Portuguesa do Translation Project
> http://www2.iro.umontreal.ca/~pinard/po/registry.cgi?team=pt
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list