* [gentoo-user] Getting BC not to truncate at the decimal point?
@ 2006-05-24 16:48 Mike Huber
2006-05-24 21:49 ` [SPAM] - [gentoo-user] Getting BC not to truncate at the decimal point? - Bayesian Filter detected spam Harald Arnesen
2006-05-25 16:05 ` [gentoo-user] Getting BC not to truncate at the decimal point? John Green
0 siblings, 2 replies; 4+ messages in thread
From: Mike Huber @ 2006-05-24 16:48 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]
Hi,
I'm just trying to do some quick calculations using bc, but the version
installed through portage truncates on multiplication/division. It didn't
used to do this 2 years ago when I was taking number theory, and there are
no USE flags available for sys-devel/bc to change this. From the manpage:
---------------------------------------------------------------------
The most basic element in bc is the number. Numbers are arbitrary precision
numbers. This precision is both in the integer part and the fractional
part. All numbers are represented internally in decimal and all computation
is done in decimal. (This version truncates results from divide and
multiply operations.) There are two attributes of numbers, the length and
the scale. The length is the total number of significant decimal digits
in a number and the scale is the total number of decimal digits after the
decimal point. For example:
.000001 has a length of 6 and scale of 6.
1935.000 has a length of 7 and a scale of 3.
------------------------------------------------------------------------
Anyone have any ideas?
--Mike
[-- Attachment #2: Type: text/html, Size: 1642 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [SPAM] - [gentoo-user] Getting BC not to truncate at the decimal point? - Bayesian Filter detected spam
2006-05-24 16:48 [gentoo-user] Getting BC not to truncate at the decimal point? Mike Huber
@ 2006-05-24 21:49 ` Harald Arnesen
2006-05-26 1:38 ` znx
2006-05-25 16:05 ` [gentoo-user] Getting BC not to truncate at the decimal point? John Green
1 sibling, 1 reply; 4+ messages in thread
From: Harald Arnesen @ 2006-05-24 21:49 UTC (permalink / raw
To: gentoo-user
"Mike Huber" <michael.huber@gmail.com> writes:
> Hi,
> I'm just trying to do some quick calculations using bc, but the version
> installed through portage truncates on multiplication/division. It didn't
> used to do this 2 years ago when I was taking number theory, and there are
> no USE flags available for sys-devel/bc to change this. From the manpage:
$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
101/3
33
$ bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
101/3
33.66666666666666666666
--
Hilsen Harald.
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [SPAM] - [gentoo-user] Getting BC not to truncate at the decimal point? - Bayesian Filter detected spam
2006-05-24 21:49 ` [SPAM] - [gentoo-user] Getting BC not to truncate at the decimal point? - Bayesian Filter detected spam Harald Arnesen
@ 2006-05-26 1:38 ` znx
0 siblings, 0 replies; 4+ messages in thread
From: znx @ 2006-05-26 1:38 UTC (permalink / raw
To: gentoo-user
On 24/05/06, Harald Arnesen <harald@skogtun.org> wrote:
> "Mike Huber" <michael.huber@gmail.com> writes:
>
> > Hi,
> > I'm just trying to do some quick calculations using bc, but the version
> > installed through portage truncates on multiplication/division. It didn't
> > used to do this 2 years ago when I was taking number theory, and there are
> > no USE flags available for sys-devel/bc to change this. From the manpage:
>
> $ bc
> bc 1.06
> Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
> This is free software with ABSOLUTELY NO WARRANTY.
> For details type `warranty'.
> 101/3
> 33
>
> $ bc -l
> bc 1.06
> Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
> This is free software with ABSOLUTELY NO WARRANTY.
> For details type `warranty'.
> 101/3
> 33.66666666666666666666
> --
> Hilsen Harald.
>
> --
> gentoo-user@gentoo.org mailing list
>
>
Hi,
I have always understood bc has always truncated (or at least through
my general usage) whenever I have needed it to grow the decimal
precision I use the scale= option:
$ echo "101/3" | bc
33
$ echo "scale=10; 101/3" | bc
33.6666666666
$ echo "scale=3; 101/3" | bc
33.666
$ echo "101/3" | bc -l
33.66666666666666666666
-l auto sets the scale to 20 (as per manpage). Same version of bc.
Thanks
Mark
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Getting BC not to truncate at the decimal point?
2006-05-24 16:48 [gentoo-user] Getting BC not to truncate at the decimal point? Mike Huber
2006-05-24 21:49 ` [SPAM] - [gentoo-user] Getting BC not to truncate at the decimal point? - Bayesian Filter detected spam Harald Arnesen
@ 2006-05-25 16:05 ` John Green
1 sibling, 0 replies; 4+ messages in thread
From: John Green @ 2006-05-25 16:05 UTC (permalink / raw
To: gentoo-user
Mike Huber wrote:
> Hi,
> I'm just trying to do some quick calculations using bc, but the
> version installed through portage truncates on
> multiplication/division. It didn't used to do this 2 years ago when I
> was taking number theory, and there are no USE flags available for
> sys-devel/bc to change this. From the manpage:
>
> ---------------------------------------------------------------------
>
> The most basic element in bc is the number. Numbers are arbitrary
> precision numbers. This precision is both in
> the integer part and the fractional part. All numbers are
> represented internally in decimal and all computation is done in
> decimal. ( This version truncates results from divide and multiply
> operations.) There are two attributes of numbers, the length and the
> scale. The length is the total number of significant decimal digits
> in a number and the scale is the total number of decimal digits after
> the decimal point. For example:
> .000001 has a length of 6 and scale of 6.
> 1935.000 has a length of 7 and a scale of 3.
>
>
> ------------------------------------------------------------------------
>
>
> Anyone have any ideas?
>
> --Mike
Hi,
Try this.
$ echo '1/5' | bc
0
$ echo '1/5' | bc -l
.20000000000000000000
I don't think bc has changed in a long time.
Maybe you forgot the -l option.
You can also control the scale explicitly like this.
echo 'scale=3;1/5' | bc -l
.200
Hope this helps.
John Green
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-05-26 1:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-24 16:48 [gentoo-user] Getting BC not to truncate at the decimal point? Mike Huber
2006-05-24 21:49 ` [SPAM] - [gentoo-user] Getting BC not to truncate at the decimal point? - Bayesian Filter detected spam Harald Arnesen
2006-05-26 1:38 ` znx
2006-05-25 16:05 ` [gentoo-user] Getting BC not to truncate at the decimal point? John Green
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox