Hi Ralph, On 4/28/23 11:34, Ralph Corderoy wrote: > 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.
Would you please share that? I'm curious. I could only see this: $ echo 'l(1114112) / l(2)' | bc -lc @iK1114112:C2,0:K2:C2,0:/W@r @i $ echo 'l(1114112) / l(2)' | /usr/lib/plan9/bin/bc -c 1114112 l<12>x 2 l<12>x/ps. q $ echo 'l(1114112) / l(2)' | /usr/lib/plan9/bin/bc -lc c[cannot open input file:1, ]pc 1114112 l<12>x 2 l<12>x/ps. q > > 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. Makes sense. Cheers! Alex -- <http://www.alejandro-colomar.es/> GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
OpenPGP_signature
Description: OpenPGP digital signature
