Re: [dev] suckless bignum library

From: Evan Gates <evan.gates_AT_gmail.com>
Date: Thu, 10 Dec 2015 09:41:21 -0800

On Thu, Dec 10, 2015 at 7:30 AM, FRIGN <dev_AT_frign.de> wrote:
> but just a library with just enough functions to get around with
> to handle tasks like dc(1) and bc(1).

The problem with that is bc can't use a normal bignum library and be
POSIX compliant as all the internal math is required to be in base 10.
"Internal computations shall be conducted as if in decimal, regardless
of the input and output bases, to the specified number of decimal
digits."[0] That's why implementations of bc tend to have their own
arbitrary precision stuff built in.

That being said a suckless bignum library can still be very useful,
and sbase tends to stray from POSIX in a few places. This may be one
such place that makes sense to ignore POSIX. For bc we need simple
arithmetic, sqrt, integer exponents, sine, cosine, arctangent, natural
log, exponential function, Bessel function of integer order, and a way
to work with the bc concept of scale.[0] Depending on your performance
desires many those can either be implemented in the library or in bc
using a simpler library.

One last off topic question, should sbase have a bc that calculates,
or just translates to dc (which is not a POSIX tool, but probably
useful to have in sbase).

-emg

[0] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html#tag_20_09_13_03
Received on Thu Dec 10 2015 - 18:41:21 CET

This archive was generated by hypermail 2.3.0 : Thu Dec 10 2015 - 18:48:15 CET