Re: [R] Odd results with %% and conserving memory

2010-04-06 Thread Thomas Lumley
On Tue, 6 Apr 2010, JustinNabble wrote: Likewise, identical( (4.1 * 100 ) %/% 1 , 409 ) returns TRUE on my computer, so the result is off by exactly 1, too larger to be explained by floating point error. The result of (4.1 * 100 ) %/% 1 is an integer, so if it doesn't agree exactly it has to

Re: [R] Odd results with %% and conserving memory

2010-04-06 Thread Steve Lianoglou
Hi, On Tue, Apr 6, 2010 at 5:26 PM, JustinNabble wrote: > > Thanks for the response. I read through the Inferno and there's a lot of > useful stuff in there. However I think you may have missed something. > > Having some experience with other languages, I know that floating point > numbers aren't

Re: [R] Odd results with %% and conserving memory

2010-04-06 Thread Bert Gunter
(4.1*100) %/% 1 [1] 409 ?"%/%" Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of JustinNabble Sent: Tuesday, April 06, 2010 2:27 PM To: r-help@r-project.org Subject: Re: [R] Odd r

Re: [R] Odd results with %% and conserving memory

2010-04-06 Thread JustinNabble
Thanks for the response. I read through the Inferno and there's a lot of useful stuff in there. However I think you may have missed something. Having some experience with other languages, I know that floating point numbers aren't represented exactly, the issue is that R is off by much more than w

Re: [R] Odd results with %% and conserving memory

2010-03-27 Thread jim holtman
FAQ 7.31 Follow the link to what you should know about floating point numbers. On Fri, Mar 26, 2010 at 5:05 PM, JustinNabble wrote: > > Can anyone explain this? > > I have a matrix with double components. It's taking up a lot of memory, so > I > want to multiply then turn it to integers. I'm pre

Re: [R] Odd results with %% and conserving memory

2010-03-27 Thread Patrick Burns
You seem to be in Circle 1 of 'The R Inferno'. Your technique does work, just not the way that you expect. Try doing: range( (mat * 100) %% 1) The 'zapsmall' function might be of interest as well. On 26/03/2010 21:05, JustinNabble wrote: Can anyone explain this? I have a matrix with double

[R] Odd results with %% and conserving memory

2010-03-27 Thread JustinNabble
Can anyone explain this? I have a matrix with double components. It's taking up a lot of memory, so I want to multiply then turn it to integers. I'm pretty certain that there are only 2 decimal places, but I wanted to check by using modulo. E.g. mat = matrix(11:50/100, ncol=4,nrow=10) #Matrix wi