bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bc "remainder" operation malfunctions if scale!=0


From: Harald Anlauf
Subject: Re: bc "remainder" operation malfunctions if scale!=0
Date: 27 Dec 2000 11:27:22 +0100

address@hidden (Erik Rossen) writes:

> Is the following behavior normal for the remainder operation?
> 
> bc 1.05
> Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software Foundation,
> Inc.
> This is free software with ABSOLUTELY NO WARRANTY.
> For details type `warranty'. 
> scale=0
> 5%4
> 1
> scale=6
> 5%4
> 0

RTFM!

       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 inte­
              gers this expression is the integer remainder func­
              tion.

Try e.g., scale=1, and then you'll see that bc is right (this time).

-- 
Ciao,
-ha



reply via email to

[Prev in Thread] Current Thread [Next in Thread]