groff
[Top][All Lists]
Advanced

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

Re: bc and dc. (Was: neatroff for Russian.)


From: Ralph Corderoy
Subject: Re: bc and dc. (Was: neatroff for Russian.)
Date: Fri, 28 Apr 2023 10:34:26 +0100

Hi Alejandro,

None of the below may apply to GNU's bc and dc.  I prefer Unix.

> bc(1) on the contrary, is likely to be using 'long double', for being
> able to provide so many digits.

No, bc doesn't use a C language or machine type.  The precision can
be set.

    $ bc -l
    scale=42
    l(1114112) / l(2)
    20.087462841250339408254066010810404354011270
    $

bc's l() function is written in bc rather than a built-in and can be
read for fun.  bc uses dc(1) to do the work and can be asked to ‘compile
only’ with -c.  dc has k to set the precision; bc's scale simply uses k.

dc uses a byte to store each pair of decimal digits.  This allows
overflow within the byte during calculations and makes it quick to
perform the common case of formatting the many-byte number to
decimal-digit text.

-- 
Cheers, Ralph.



reply via email to

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