bug-bash
[Top][All Lists]
Advanced

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

Re: About fltexpr


From: Duncan Roe
Subject: Re: About fltexpr
Date: Mon, 22 Sep 2025 13:03:54 +1000

On Mon, Sep 22, 2025 at 03:06:51AM +0200, pourko@tutamail.com wrote:
> On Mon, 22 Sep 2025 10:49:03 +1000 Duncan Roe wrote:
> > Indeed. I was thinking about a previous post where someone suggested printf,
> > which could round the answer to less digits. That's what you want isn't it?
>
> There's printf in Bash, and there's printf in C. Why would I have to do
> it in Bash, when the correct output can come directly from the C program?
>
> Besides, I can't readily clean up the trailing zeros with printf, I will
> still have to do some extra juggling on top of that, to get the answer "0.3".
>
> And no, I can't simply tell printf to print me only one digit after the dot,
> because I don't know beforehand how many digits the answer will have.
>
>
$ printf '%g\n' $(fltexpr -p '0.1 + 0.2')
0.3



reply via email to

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