Dear All, The following code should return 1, but it returns 0: source("http://r-bc.googlecode.com/svn/trunk/R/bc.R") bc("9 % 2") Do you confirm this bug? Paul
Paul Smith <phhs80 <at> gmail.com> writes:> > Dear All, > > The following code should return 1, but it returns 0: > > source("http://r-bc.googlecode.com/svn/trunk/R/bc.R") > bc("9 % 2") > > Do you confirm this bug? >It's not a bug in r-bc, it's a misfeature (?) in bc. It has to do with the 'scale' parameter in bc (which gets set to 100 explicitly by r-bc, but would be set to 20 in any case by the use of the '-l' option to bc) http://superuser.com/questions/31445/gnu-bc-modulo-with-scale-other-than-0 http://en.wikipedia.org/wiki/Bc_programming_language http://www.linuxquestions.org/questions/programming-9/bc-using-l-messes-up-modulus-331003/ a workaround;> source("http://r-bc.googlecode.com/svn/trunk/R/bc.R") > bc("scale=0; 9%2")[1] "1"
On Mon, Jul 26, 2010 at 1:44 PM, Paul Smith <phhs80 at gmail.com> wrote:> Dear All, > > The following code should return 1, but it returns 0: > > source("http://r-bc.googlecode.com/svn/trunk/R/bc.R") > bc("9 % 2") >See FAQ 2 on the r-bc package home page: http://r-bc.googlecode.com
On Mon, Jul 26, 2010 at 11:42 PM, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:>> The following code should return 1, but it returns 0: >> >> source("http://r-bc.googlecode.com/svn/trunk/R/bc.R") >> bc("9 % 2") >> > > See FAQ 2 on the r-bc package home page: > http://r-bc.googlecode.comThanks to all respondents for your replies. It seems that there is still a problem:> bc("2 % 50",sample=0)[1] "0" However,> bc("scale = 0; 2 % 50")[1] "2">Paul
Gabor Grothendieck <ggrothendieck <at> gmail.com> writes:> See FAQ 2 on the r-bc package home page: > http://r-bc.googlecode.comThis is getting a little bit self-referential -- that FAQ refers to the previous?message in this thread ...
On Mon, Jul 26, 2010 at 10:00 PM, Ben Bolker <bbolker at gmail.com> wrote:> Gabor Grothendieck <ggrothendieck <at> gmail.com> writes: > >> See FAQ 2 on the r-bc package home page: >> http://r-bc.googlecode.com > > ?This is getting a little bit self-referential -- that FAQ refers to > the previous?message in this thread ... >The above was written before I saw your post but (in fact I had an entire offline conversation with the poster) but when I did see it the links and other info seemed so useful that I improved the FAQ and linked to it.
On Mon, Jul 26, 2010 at 6:54 PM, Paul Smith <phhs80 at gmail.com> wrote:> On Mon, Jul 26, 2010 at 11:42 PM, Gabor Grothendieck > <ggrothendieck at gmail.com> wrote: >>> The following code should return 1, but it returns 0: >>> >>> source("http://r-bc.googlecode.com/svn/trunk/R/bc.R") >>> bc("9 % 2") >>> >> >> See FAQ 2 on the r-bc package home page: >> http://r-bc.googlecode.com > > Thanks to all respondents for your replies. It seems that there is > still a problem: > >> bc("2 % 50",sample=0) > [1] "0"Its scale=0, not sample=0> bc("2 % 50", scale=0)[1] "2"> bc("scale=0; 2 % 50")[1] "2"> options(bc.scale=0) > bc("2 % 50")[1] "2"
On Tue, Jul 27, 2010 at 5:12 AM, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:>>>> The following code should return 1, but it returns 0: >>>> >>>> source("http://r-bc.googlecode.com/svn/trunk/R/bc.R") >>>> bc("9 % 2") >>>> >>> >>> See FAQ 2 on the r-bc package home page: >>> http://r-bc.googlecode.com >> >> Thanks to all respondents for your replies. It seems that there is >> still a problem: >> >>> bc("2 % 50",sample=0) >> [1] "0" > > Its scale=0, ?not sample=0 > >> bc("2 % 50", scale=0) > [1] "2" > >> bc("scale=0; 2 % 50") > [1] "2" > >> options(bc.scale=0) >> bc("2 % 50") > [1] "2" >That is right! Sorry and thanks, Gabor. Paul