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 08:59:00 +0200
User-agent: Mozilla Thunderbird

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.

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

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