Skip to content
Back to formatted view

Raw Message

Message-ID: <49CFD2E8.8090908@unicas.it>
Date: 2009-03-29T19:58:32Z
From: Domenico Vistocco
Subject: binary AND operators in R
In-Reply-To: <6B32C438581E5D4C8A34C377C3B334A401752A39@FBCMST11V04.fbc.local>

You should find the functions:

 bitAnd, bitOr and bitXor

in the bitops package.

Ciao,
domenico

mauede at alice.it wrote:
> I cannot find any R function or operator that performs a binary AND operation, as performed by Fortran built-in function "iand".
> Ideally either R operator "&" or "&&" should do that. But some tests proved they do not:
>   
>> A<- 1
>> B <- 2
>> A
>>     
> [1] 1
>   
>> B
>>     
> [1] 2
>   
>> as.numeric(A&B)
>>     
> [1] 1
>   
>> as.numeric(A&&B)
>>     
> [1] 1
>
> The binary content of A should be "10000"
> The binary content of B should be "01000"
> Therefore the  bitwise AND operator should yield 0 !
> I do not know how to fore the binary representation of an unsigned integer when writing  R code. 
> Do you know how to get around this problem ?
>
> Thank you so much.
> Maura
>
>
> tutti i telefonini TIM!
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>