Re: [Rd] C function, double problem

From: Rui Barradas <ruipbarradas_at_sapo.pt>
Date: Sat, 08 Dec 2012 15:47:27 +0000

Hello,

The double in R and the double in C are the same type, with the same number of decimals (64 bits), so it's not because the numbers are too long. Try calling .C("function", other parameters, result = double(quantity)). Or maybe the error is in the C code, of which we know nothing about.

Rui Barradas
Em 08-12-2012 02:26, mpietro escreveu:
> Hi everybody,
>
> here's my problem:
>
> i call a C function which calculates a large number of double values and
> puts them into an array which is passed from R as a parameter in the
> function (like .C("function", other parameters, result = as.double( c ( 1
> : quantity ) ).
> When the values come back to R in the result array, they are all truncated
> to their integer value (i.e. I lose the decimal parts).
> I think that the problem is that this calculated double numbers are actually
> too long, with many decimals, because i changed in code the calculated
> values with arbitrary double values with a few decimals and it works.
>
> Has anybody any idea of where the problem is?
>
> Thanks in advance!
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/C-function-double-problem-tp4652537.html
> Sent from the R devel mailing list archive at Nabble.com.
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat 08 Dec 2012 - 15:51:30 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 08 Dec 2012 - 23:22:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive