>Could fltexpr maybe link to some other libm that is correctly rounded,
>like GNU MPFR, or LLVM's libm, to mention just a few?
I doubt they'd want to make bash dependent on any external library
like that (that may or may not be installed on a given system).
But you are certainly welcome to take a look at the source (fltexpr.c)
and monkey around with it. It doesn't look that hard to me; there are
only 3 or 4 "print" statements in it. It looks like the one "snprintf"
is where the number to string conversion takes place; you could
probably fix that yourself.
Interestingly, I tried messing around a bit with MPFR using GAWK, but
found it did pretty much the same thing as fltexpr does - which is not
what you want.
The other thing I wanted to suggest - since you've opened the door to
suggesting alternatives - is to run "bc" as a coproc. Note that I am
*not* suggesting running bc in the normal "one shot" mode - where
you'd have to run it ("shelling out" as you put it) once for each
calculation you need to make.
Rather, if you run it as a coproc, you run it just once and you then
communicate with it each time you need to do a calculation. The last
time I needed to do floating point math in a bash script - which was
years ago - I did it this way and it worked out quite well.
Unless you've already thought of and rejected this idea, you might
want to consider it. I don't know how much you know about coprocs in
bash, but it is worth looking into.
=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.
When responding to my posts, please try to refrain from giving bureaucratic
answers.
If you have nothing useful to say, then just click Next and go on.