learnpython.org - an online interactive Python tutorial

Dave Angel davea at ieee.org
Sun Apr 24 07:16:15 EDT 2011


On 01/-10/-28163 02:59 PM, harrismh777 wrote:
> Cameron Simpson wrote:
>> | folks are not aware that 'bc' also has arbitrary precision floating
>> | point math and a standard math library.
>>
>> Floating point math? I thought, historically at least, that bc is built
>> on dc (arbitrary precision integer math, reverse polish syntax) and that
>> consequently bc uses fixed point math rather than floating point.
>
> My bad... I don't mean under-the-covers... I mean that the user may
> calculate arbitrary precision floating arithmetic ... bc keeps track of
> the decimal point and displays the number of digits the user specifies;
> arbitrary precision calculator. (loose language, sorry)
>
> On a *nix system, Mac OSx, Linux, run this to get 1000+ digits of PI:
>
> time echo "scale = 1010; 16 * a(1/5) - 4 * a(1/239)" |bc -lq
>
>
>
> scale sets the precision, -lq loads the math library arctan() quiet.
>
>
>

Wouldn't it be shorter to say:

time echo "scale = 1010;  4 * a(1)" |bc -lq

DaveA



More information about the Python-list mailing list