From martin.becker at mx.uni-saarland.de  Wed Apr  4 09:24:15 2007
From: martin.becker at mx.uni-saarland.de (Martin Becker)
Date: Wed, 04 Apr 2007 09:24:15 +0200
Subject: [Rd] Strange number produced by dnorm
In-Reply-To: <dc3f83df14128.4611afd3@usc.edu>
References: <dc3f83df14128.4611afd3@usc.edu>
Message-ID: <4613529F.7090406@mx.uni-saarland.de>

Hi,

I think the only thing that's wrong is "%d" in your printf statement, 
shouldn't it be "%f"? ("%d" is used for decimal (integer) numbers, "%f" 
for float (double) numbers)

Regards,

  Martin

Tong Wang wrote:
> Hi All,
>     I just started to learn compiling C codes for R usage, and got a problem when I was playing with my 'hello world' code. 
>   
> #include <R.h>
> #include <Rdefines.h>    
> #include <Rmath.h>
>
> SEXP test( ) {
>   double x;
>   x=dnorm(1.0,0.0,1.0,1);
>   printf(" x value is: %d \n",x);
>   return(R_NilValue);
> }
>
>    I got the result :    x value is: -466460838 
>
> Could someone explain to me what was wrong here ?
>
> Thanks a lot. 
>
> tong
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] Strange number produced by dnorm
Martin Becker