[R] Floats in Microsoft Basic format
Duncan Murdoch
murdoch.duncan at gmail.com
Wed Aug 10 16:20:22 CEST 2011
On 10/08/2011 10:16 AM, Barry Rowlingson wrote:
> On Wed, Aug 10, 2011 at 2:34 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com> wrote:
> > On 10/08/2011 5:58 AM, taraxacum wrote:
> >>
> >> Hi all,
> >> I need to convert a floating point value from Microsoft Basic format to
> >> IEEE
> >> format.
> >> There's a simple way to achieve this in R or I have to write my own
> >> function?
> >> (e.g. convert the C code below)
> >
> > You'll need to write your own function. It can be very similar to what you
> > have below, except:
> > - you'll need to produce double rather than single (easy, just produce a
> > single and assign to a double, C does the conversion for you)
> > - you need to change the args to your function to some that R understands.
>
> Wouldn't it be easier, given a working C implementation, to write a
> wrapper that calls the C code? R isn't built for bit-twiddling, C very
> definitely is.
That's actually what I was suggesting.
Duncan Murdoch
> Also, I imagine you may have a large number of these to change, in
> which case you could do it all with a single call to a C function that
> loops over the numbers from an R vector.
>
> See the R docs for how to load compiled C into R.
>
> Barry
More information about the R-help
mailing list