chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] My code doesn't float


From: Paul Colby
Subject: [Chicken-users] My code doesn't float
Date: Tue, 16 Aug 2011 21:15:53 -0700

Hi,

I'm running v4.7.0 installed with brew on my mac running 10.6. Before I do a 
complete reinstall of my operating system I'd like to know if foreign works for
anyone? I've made a c-file,

-------------------------- test1.c -----------------------
#include <stdio.h>

float testFloat(float f)
{
  printf("Float: %f\n",f);
  return 2.0*f;
}

double testDouble(double d)
{
  printf("Double: %lf\n",d);
  return 2.0*d;
}
------------------------------ end of file -----------------
These functions are compiled into a scheme 
file using
csc stest2.scm test1.c
where the scheme file is,
------------------------ stest2.scm ----------------------
(import foreign)
(define testFloat (foreign-lambda float testFloat float))
(define testDouble (foreign-lambda double testDouble double))
(print (testFloat 3.2))
(print (testDouble 3.2))
----------------------- end of file ------------------------
running ./stest2 gives
------------------------ output  ---------------------------
Float: -0.000000
17.0
Double: 3.200000
17.0
------------------------ end of output -------------------

Am I missing something fundamental or is 3.2 == -0.0 and 
17==6.4? 

Thanks
Paul C.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]