[BioC] Is this a basic bug or something else ?
James W. MacDonald
jmacdon at uw.edu
Tue Mar 13 14:56:09 CET 2012
Hi Alok,
This isn't a question for the BioC listserv, as this has nothing to do
with any BioC packages. Please direct these sorts of questions to R-help.
And before you go to R-help and get pasted for not understanding the
intricacies of floating point arithmetic in binary systems, please see
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
Best,
Jim
On 3/13/2012 9:41 AM, ALok wrote:
> Dear R User,
> I wrote a simple script in R, just to calculate the sum of the vector
>
> ###################
> New<-function(n,old)
> {
> tt=0
> k=length(old)
> for(i in 1:k)
> {
> # print(i)
> tt=tt+old[i]
> # print(tt)
> }
> print(tt)
> print(n)
> print(k)
> if (n == tt){
> print ("A--Input is right")
> }
> if (n != tt){
> print ("B--Input is wrong")
> }
> }
> ###################
>
> Now, I am testing it for two variable:
> for
>
> n=13
>
> old1= as.vector(c(2.8,2.8,2.8,1.1,0.7,2.8))
> and
> # I have just swaped the 3rd and 4th variable
> old2= c(2.8,2.8,1.1,2.8,0.7,2.8)
>
> # The first vector returns,
>> New(n,old1)
> [1] "B--Input is wrong"
>
> # While the second Vector returns,
>> New(n,old2)
> [1] "A--Input is right"
>
> Does anybody have some idea, Why is it so, Ideally both should be TRUE ?????
>
> Alok
>
>
--
James W. MacDonald, M.S.
Biostatistician
University of Washington
Environmental and Occupational Health Sciences
4225 Roosevelt Way NE, # 100
Seattle WA 98105-6099
More information about the Bioconductor
mailing list