Re: integer or float?
Lawrence Velázquez <[email protected]> Thu, 02 Oct 2025 11:39:02 -0400
| Newsgroups | gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Oct 2, 2025, at 9:10 AM, Ray Andrews wrote: > However the above: > > % unsetopt FORCE_FLOAT > % echo $((1.0)) > 1. > > ... really does seem like a mistake: It's not a mistake. > % setopt forcefloat; echo $((1.0)) > 1. > > % unsetopt forcefloat; echo $((1.0)) > 1. > > % unsetopt forcefloat; echo $((1)) > 1 > > % setopt forcefloat; echo $((1)) > 1. The third expression has an integer value and is displayed as such. The other three have floating point values (due to the use of a floating-point literal or FORCE_FLOAT) and are displayed as such. > contrast the uniform an correct output here: > > % setopt forcefloat; echo $((.5)) > 0.5 > > % unsetopt forcefloat; echo $((.5)) > 0.5 > > % setopt forcefloat; echo $((0.5)) > 0.5 > > % unsetopt forcefloat; echo $((0.5)) > 0.5 All four of these expressions have floating-point values and are displayed as such. There is no inconsistency here. > ... note that above zsh actually 'fixes it for you': '.5' becomes > '0.5'. So we have rigor with leading zeros but not trailing zeros. Please stop using terms like "rigor" and "correct" to express your personal aesthetic preferences. -- vq