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"

______________________________________________
R-help@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.

Reply via email to