Le 05/06/2024 à 17:09, Koichi Murase écrivait :
2024年6月5日(水) 21:41 Zachary Santer <zsan...@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.

LC_MESSAGES=C LC_NUMERIC=fr_FR.UTF8 printf '%f\n' 3.1415
bash: printf: 3.1415: invalid number
3,000000


Chet explained it is because Bash is following the POSIX norm and C printf rules.

Now imagine if Bash introduce floating-point support, you write a Bash script with decimal point floating-point numbers and your script is incompatible with systems whose locale use a decimal comma instead.


--
Léa Gris

Reply via email to