1 |
On 24/05/06, Harald Arnesen <harald@×××××××.org> wrote: |
2 |
> "Mike Huber" <michael.huber@×××××.com> writes: |
3 |
> |
4 |
> > Hi, |
5 |
> > I'm just trying to do some quick calculations using bc, but the version |
6 |
> > installed through portage truncates on multiplication/division. It didn't |
7 |
> > used to do this 2 years ago when I was taking number theory, and there are |
8 |
> > no USE flags available for sys-devel/bc to change this. From the manpage: |
9 |
> |
10 |
> $ bc |
11 |
> bc 1.06 |
12 |
> Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. |
13 |
> This is free software with ABSOLUTELY NO WARRANTY. |
14 |
> For details type `warranty'. |
15 |
> 101/3 |
16 |
> 33 |
17 |
> |
18 |
> $ bc -l |
19 |
> bc 1.06 |
20 |
> Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. |
21 |
> This is free software with ABSOLUTELY NO WARRANTY. |
22 |
> For details type `warranty'. |
23 |
> 101/3 |
24 |
> 33.66666666666666666666 |
25 |
> -- |
26 |
> Hilsen Harald. |
27 |
> |
28 |
> -- |
29 |
> gentoo-user@g.o mailing list |
30 |
> |
31 |
> |
32 |
|
33 |
Hi, |
34 |
|
35 |
I have always understood bc has always truncated (or at least through |
36 |
my general usage) whenever I have needed it to grow the decimal |
37 |
precision I use the scale= option: |
38 |
|
39 |
$ echo "101/3" | bc |
40 |
33 |
41 |
$ echo "scale=10; 101/3" | bc |
42 |
33.6666666666 |
43 |
$ echo "scale=3; 101/3" | bc |
44 |
33.666 |
45 |
$ echo "101/3" | bc -l |
46 |
33.66666666666666666666 |
47 |
|
48 |
-l auto sets the scale to 20 (as per manpage). Same version of bc. |
49 |
|
50 |
Thanks |
51 |
Mark |
52 |
|
53 |
-- |
54 |
gentoo-user@g.o mailing list |