Skip to content
Back to formatted view

Raw Message

Message-ID: <48DC0D69.5090805@witthoft.com>
Date: 2008-09-25T22:15:05Z
From: Carl Witthoft
Subject: Conversion to Binary (base2)

It occurs to me that Christos' method could be made more flexible by 
using rle().  That is, before collapsing the digits,  you have something 
like

 >foo
[1] 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 0

Then rle(foo) will show you where the boring lead-zeros end, and you can 
use that value to set the truncation ---- rather than a fixed [1:17] as 
below.

Carl

quote:
This was what I was looking for to solve the truncate to 17 digits. 
Thanks a lot.

Now my output looks like this:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ,0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ,0.0998004
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ,0.1996008



On Thu, Sep 25, 2008 at 4:28 PM, Christos Hatzis < 
christos.hatzis_at_nuverabio.com> wrote:

 > paste(rev(as.integer(intToBits(as.integer(x))[1:17])), collapse="")
endquote