bug-bash
[Top][All Lists]
Advanced

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

Re: REQUEST - bash floating point math support


From: Léa Gris
Subject: Re: REQUEST - bash floating point math support
Date: Thu, 6 Jun 2024 09:03:20 +0200
User-agent: Mozilla Thunderbird

Le 05/06/2024 à 17:09, Greg Wooledge écrivait :
On Wed, Jun 05, 2024 at 09:57:26PM +0700, Robert Elz wrote:
Also note that to actually put floating support in the shell, more is
needed than just arithmetic, you also need floating comparisons in test
(or in bash, in [[ ) and a whole bunch more odds and ends that aren't
obvious until you need them, and they're just not there (like a mechanism
to convert floats back into integers again, controlling how rounding happens).

Ironically, that last one is the one we already *do* have.

hobbit:~$ printf '%.0f\n' 11.5 22.5 33.5
12
22
34

As long as you're OK with "banker's rounding", printf does it.

As long as you are ok with your script breaking because of LC_NUMERIC local using a different decimal symbol like a comma in French.


--
Léa Gris


reply via email to

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