[R] How to get correct integration in C for step function?
tlumley at u.washington.edu
Mon Jan 22 20:37:01 CET 2007
On Mon, 22 Jan 2007, Lynette wrote:
> Dear all, especially to Thomas,
> I have figured out the problem. For the step function, something wrong with
> my C codes. I should use the expression ((x>=0.25)&&(x<=0.75)) ? 2:1 instead
> of ((x>=1/4)&&(x<=3/4)) ? 2:1 ). Have no idea why 0.25 makes difference from
> 1/4 in C. But now I can go ahead with the correct integration in C. Thank you
> all. And hope this helps to others.
1 and 4 are ints in C, so 1/4 is 0 (integer division).
More information about the R-help