On Sun, Sep 21, 2025 at 12:03:10 -0600, Stan Marsh wrote:
> 
> >Bourne Again SHell wrote:
> >> $ fltexpr -p "0.1 + 0.2"
> >> 0.30000000000000004
> 
> >> https://0.30000000000000004.com/
> 
> Of course there are no bugs in the OP and, of course, just about
> everything there is covered by the usual "What every computer
> programmer should know about floating point math" cliche.
> 
> Still, I suppose an argument could be made that fltexpr could be
> changed to generate more human-friendly results (like bc does) - maybe
> by specifying a number of digits to keep and only displaying that
> much.
> 
> It would save us all some number of "bug" reports.

Use printf to round results for human display.  This applies to any
floating point values you get from anywhere, whether that's fltexpr,
bc, awk, python, etc.

Otherwise, you're *always* going to run into issues of this type.

Reply via email to