|
| From: | Léa Gris |
| Subject: | Re: REQUEST - bash floating point math support |
| Date: | Thu, 6 Jun 2024 11:08:59 +0200 |
| User-agent: | Mozilla Thunderbird |
Le 06/06/2024 à 10:29, Koichi Murase écrivait :
2024年6月6日(木) 15:59 Léa Gris <lea.gris@noiraude.net>:Le 05/06/2024 à 17:09, Koichi Murase écrivait :2024年6月5日(水) 21:41 Zachary Santer <zsanter@gmail.com>:Bash could potentially detect floating point literals within arithmetic expansions and adjust the operations to use floating point math in that case. [...]ksh and zsh are already behaving in that way, and if Bash would support the floating-point arithmetic, Bash should follow their behavior.Bash isn't even consistent with the floating point data/input format when using printf '%f\n' "$float_string" as it depends on LC_NUMERIC locale.Maybe I miss your point, but literals in arithmetic expressions and the printf format are unrelated.
They are in Bash. Bash use the locale format for floating-point number arguments.
It means:printf %f will break when the argument contains a floating-point number using a different decimal symbol than that of the current locale in the LC_NUMERIC environment variable.
For example, if LC_NUMERIC=fr_FR.UTF8, the decimal separator symbol is a comma (not a dot) and printf %s 0.1 will fail because 0.1 is not recognized as a valid floating-point number argument by printf.
The implication of this behaviour on floating-point implementation is that the values will not be compatible with all system locale since Bash does not allow a consistent format for the decimal separator symbol when passing floating-point numbers arguments to printf.
-- Léa Gris
| [Prev in Thread] | Current Thread | [Next in Thread] |