[Rd] Strange number produced by dnorm
Tong Wang
wangtong at usc.edu
Mon Apr 9 03:13:33 CEST 2007
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.
>
>
More information about the R-devel
mailing list