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: Fri, 14 Jun 2024 09:18:11 +0200
User-agent: Mozilla Thunderbird

Le 14/06/2024 à 03:41, Martin D Kealey écrivait :
On Thu, 13 Jun 2024 at 09:05, Zachary Santer <zsanter@gmail.com> wrote:


Let's say, if var is in the form of a C floating-point literal,
${var@F} would expand it to the locale-dependent formatted number, for
use as an argument to printf or for output directly. And then ${var@f}
would go the other way, taking var that's in the form of a
locale-dependent formatted number, and expanding it to a C
floating-point literal.


How about incorporating the % printf formatter directly, like ${var@%f} for
the locale-independent format and %{var@%#f} for the locale-specific format?

However any formatting done as part of the expansion assumes that the
variable holds a "number" in some fixed format, rather than a localized
string.
Personally I think this would actually be a good idea, but it would be
quite a lot bigger project than simply added FP support.

-Martin

Another elegant option would be to expand the existing variables' i flag to tell the variable is numeric rather than integer.

Then have printf handle argument variables with the numeric flag as using the LC_NUMERIC=C floating-point format with dot radix point.

Expanding the existing i flag would also ensure numerical expressions would handle the same value format.

The David method: Take down multiple issues with one stone.



--
Léa Gris


reply via email to

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