I have a C/ffi function that expects a double as an argument.
If I do (foo 0.0) <-- works fine
if I do (foo 0) <-- complains about int / double mismatch; which makes sense. Is there a way to automatically have gambit convert ints to doubles?
Thanks!
Afficher les réponses par date
On 19-May-09, at 3:48 PM, lowly coder wrote:
I have a C/ffi function that expects a double as an argument.
If I do (foo 0.0) <-- works fine
if I do (foo 0) <-- complains about int / double mismatch; which makes sense. Is there a way to automatically have gambit convert ints to doubles?
Gambit's FFI doesn't currently have such a "lenient" double type. You can do that by wrapping your function like this:
(define (lenient-foo x) (foo (exact->inexact x))
Marc