bug-bash
[Top][All Lists]
Advanced

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

Re: About fltexpr


From: Greg Wooledge
Subject: Re: About fltexpr
Date: Sun, 21 Sep 2025 14:12:58 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

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

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