Sorry, I clicked sent before completing the mail!

On Thu, Jun 18, 2009 at 9:07 AM, Kumar Appaiah <[email protected]> wrote:
>
> On Thu, Jun 18, 2009 at 9:03 AM, Mayank wrote:
> >     I'm sorry if this question has been asked before but I couldn't find
> > any appropriate answer elsewhere and hence this post. Today while doing some
> > calculation using bc I found a very peculiar thing. I was performing an
> > operation -2 % -3 and the software reported the answer as -2. Now  -2 > -3
> > and if I remember correctly then in divison operation the remainder is less
> > than the divisor. So how come in this case the answer is not coming
> > properly. Is it a software flaw or there is some mistake in my understanding
> > of the division operation ?
>
> From the bc man page:
>
> "expr % expr
>              The  result of the expression is the "remainder" and it
> is computed in the following way.  To compute a%b, first a/b is
> computed to scale digits.  That result is used to compute a-(a/b)*b to
> the scale of the maximum of scale+scale(b) and scale(a).  If scale is
> set to zero and both expressions are integers this expression is the
> integer remainder function."
>
Now, the default "scale" in bc is 0, which takes all fractions to the
integer preceding them. e.g.



--
Kumar
-- 
http://mm.glug-bom.org/mailman/listinfo/linuxers

Reply via email to