Re: [gentoo-user] Getting BC not to truncate at the decimal point?

2006-05-25 Thread John Green
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:
.01 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
.2000

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



Re: [SPAM] - [gentoo-user] Getting BC not to truncate at the decimal point? - Bayesian Filter detected spam

2006-05-25 Thread znx

On 24/05/06, Harald Arnesen [EMAIL PROTECTED] wrote:

Mike Huber [EMAIL PROTECTED] 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.
--
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.66
$ echo scale=3; 101/3 | bc
33.666
$ echo 101/3 | bc -l
33.

-l auto sets the scale to 20 (as per manpage).  Same version of bc.

Thanks
Mark

--
gentoo-user@gentoo.org mailing list



[gentoo-user] Getting BC not to truncate at the decimal point?

2006-05-24 Thread Mike Huber
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 theintegerpartandthe fractional part.All numbers are represented internally in decimal and all computation is done in decimal.(
Thisversiontruncatesresults from divide and multiply operations.)There are two attributes of numbers, the length and the scale.The length is the total number of significantdecimaldigits in a number and the scale is the total number of decimal digits after the decimal point.For example:
 .01 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


Re: [gentoo-user] Getting BC not to truncate at the decimal point?

2006-05-24 Thread brettholcomb
Did you try

scale=n

Where n is the number of digits after the decimal?  More in man bc.

 
 From: Mike Huber [EMAIL PROTECTED]
 Date: 2006/05/24 Wed PM 12:48:29 EDT
 To: gentoo-user@lists.gentoo.org
 Subject: [gentoo-user] Getting BC not to truncate at the decimal point?
 
 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:
.01 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
 
 

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Getting BC not to truncate at the decimal point?

2006-05-24 Thread Mike Huber
duh, sorry, case of me not fully reading the manpage. I'll be sure and fully read before I send to the list. Thanks a lot,--MikeOn 5/24/06, 
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Did you tryscale=nWhere n is the number of digits after the decimal?More in man bc. From: Mike Huber [EMAIL PROTECTED]
 Date: 2006/05/24 Wed PM 12:48:29 EDT To: gentoo-user@lists.gentoo.org Subject: [gentoo-user] Getting BC not to truncate at the decimal point?
 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 theintegerpartandthe fractional part.All numbers are represented internally in decimal and all computation is done in decimal.(Thisversiontruncatesresults from divide and
 multiply operations.)There are two attributes of numbers, the length and the scale.The length is the total number of significantdecimaldigits in a number and the scale is the total number of decimal digits after the
 decimal point.For example:.01 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--gentoo-user@gentoo.org mailing list


Re: [SPAM] - [gentoo-user] Getting BC not to truncate at the decimal point? - Bayesian Filter detected spam

2006-05-24 Thread Harald Arnesen
Mike Huber [EMAIL PROTECTED] 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.
-- 
Hilsen Harald.

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] Getting BC not to truncate at the decimal point?

2006-05-24 Thread Brett I. Holcomb
You're welcome.  Don't feel bad - it took me a This thing can't be that dumb 
and a man page read to find out it was smarter than I thought G.

On Wednesday May 24 2006 17:15, Mike Huber wrote:
 duh, sorry, case of me not fully reading the manpage.  I'll be sure and
 fully read before I send to the list.

 Thanks a lot,
 --Mike

 On 5/24/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  Did you try
 
  scale=n
 
  Where n is the number of digits after the decimal?  More in man bc.
 
   From: Mike Huber [EMAIL PROTECTED]
   Date: 2006/05/24 Wed PM 12:48:29 EDT
   To: gentoo-user@lists.gentoo.org
   Subject: [gentoo-user] Getting BC not to truncate at the decimal point?
  
   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:
  .01 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
 
  --
  gentoo-user@gentoo.org mailing list

-- 

Brett I. Holcomb
-- 
gentoo-user@gentoo.org mailing list