From wangtong at usc.edu  Mon Apr  9 03:13:33 2007
From: wangtong at usc.edu (Tong Wang)
Date: Sun, 08 Apr 2007 18:13:33 -0700
Subject: [Rd] Strange number produced by dnorm
In-Reply-To: <46135737.3030200@biostat.ku.dk>
References: <dc3f83df14128.4611afd3@usc.edu> <46135737.3030200@biostat.ku.dk>
Message-ID: <de1ece041195b.461930cd@usc.edu>

Having a hard time picking  up C :(      Thanks a lot for all your time .

tong

----- Original Message -----
From: Peter Dalgaard <p.dalgaard at biostat.ku.dk>
Date: Wednesday, April 4, 2007 12:44 am
Subject: Re: [Rd] Strange number produced by dnorm
To: Tong Wang <wangtong at usc.edu>
Cc: R-devel <r-devel at r-project.org>

> 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 ?
> >
> >   
> Wrong printf format. "%d" is for integers.
> 
>



[Rd] Strange number produced by dnorm
Tong Wang